Executes a OS-command.
OS-COMMAND without any options will start a new shell and not exit it - thus you will on graphical OS:es leave a window "hanging".
DEFINE VARIABLE cmd AS CHARACTER NO-UNDO.
cmd = "dir".
OS-COMMAND VALUE(cmd).
There are three options: SILENT
, NO-WAIT
and NO-CONSOLE
.
SILENT
After processing an operating system command, the AVM shell pauses. To exit the window in Windows GUI platforms, you must type exit. To exit the window in Windows character platforms, you must type exit and press RETURN or SPACEBAR. You can use the SILENT option to eliminate this pause. Use this option only if you are sure that the program, command, or batch file does not generate any output to the screen. Cannot be used with NO-WAIT.
OS-COMMAND SILENT VALUE("runprogram.exe").
NO-WAIT
In a multi-tasking environment, causes the AVM to immediately pass control back to next statement after the OS-COMMAND without waiting for the operating system command to terminate. Cannot be used with SILENT. This option is supported in Windows only.
OS-COMMAND NO-WAIT VALUE("DIR > dirfile.txt").
On Linux/Unix you will have to achieve this by preceding the command with a &
-sign instead:
OS-COMMAND VALUE("ls >> file.txt &").
NO-CONSOLE
While processing an operating system command, the AVM creates a console window. The console window may not be cleaned up after the command is executed. You can use the NO-CONSOLE option to prevent this window from being created in the first place.
OS-COMMAND NO-CONSOLE VALUE("startbach.bat").
No errors are ever returned from OS-COMMAND
to Progress ABL so you have to check for errors another way, possibly writing them to a file in a shell-script or similar.