SHELL

SHELL Command [ WAIT ] [ FOR ( READ | WRITE | READ WRITE ) [ AS Variable ]     vbdiff.jpg

Executes a command via a system shell. An internal Process object is created to manage the command.

Example :

' Get the content of a directory

SHELL "ls -la > /tmp/result" WAIT
Content = File.Load("/tmp/result")

' Same thing, but in background

SHELL "ls -la > /tmp/result" FOR READ

...

PUBLIC SUB Process_Write(Data AS String)

  Content = Content & Data

END

Differences from VB

Unlike the VB Shell command, which returns a process ID and relies on the programmer to make API calls to control the process, the Gambas Shell function optionally returns a Process object (if called with the AS parameter) which can be used to directly kill or otherwise control the spawned process. Additionally, the process may be run synchronously or asynchronously, in contrast to the VB equivalent.


Referenced by :