INTEGRAL DSL Reference Guide
Jump directly to:
::my.app.CmdLine(flags, cmdline, separator = ' ')
This function executes an external command line program.
Parameters
flags
A bitmask that can be used to customize the behavior of the function.
If 1st bit is set, the function waits for the launched external program to complete; if this bit is not set, the function does not wait but returns as soon as the external program is launched.
2nd bit is reserved for future use and must not be set.
3rd, 4th and 5th bit are interpreted as a single 3-bit value which tells the function how to redirect the external program's standard output:
- 001 = Redirect the program's output to a shared request-specific temporary file. The same shared file can be used by multiple invocations of CmdLine within a single web request. This file can be read by your INTEGRAL program using the StdOut function (because its name begins with the formatted website prefix). The file is automatically removed at the end of the current web request.
- 010 = Redirect the program's output to a serialized request-specific temporary file. Each invocation of CmdLine within a single web request creates its own unique file. These unique files can be read by your INTEGRAL program using the StdOut function (because their names begin with the formatted website prefix). The files are automatically removed at the end of the current web request.
- 011 = Redirect the program's output to a serialized long-lasting temporary file. Each invocation of CmdLine creates its own unique file. Depending on the site's path restriction policy (see LIMIT_PATH_PREFIX_R, LIMIT_PATH_PREFIX_W, LIMIT_PATH_PREFIX_U), your INTEGRAL program might not be able to read these files using the StdOut function (because their names don't begin with the formatted website prefix). These files are removed only when INTEGRAL Application Server is stopped.
- 100 = Suppress the program's standard output. This means the program's standard output is neither redirected nor sent to the console. Since no temporary files are created, the output cannot be captured using the StdOut function.
In all other cases the program's standard output is not redirected so no temporary files are created. Instead the program's standard output is sent to the console. Again, the output cannot be captured using the StdOut function.
Other bits are presently unused.
cmdline
A string that represents the entire command line. This must include the program to execute plus any arguments to pass.
The cmdline string may contain the following reserved keywords:
- {{CURR_OUTPUT}} — File name that represents the INTEGRAL output buffer.
- {{PROG_CURL}} — File name that represents the cURL
executable.
- {{PROG_ZIP}} — File name that represents the default ZIP program.
- {{PROG_PHP}} — File name that represents the default PHP interpreter.
- {{PROG_GNUPLOT}} — File name that represents the gnuplot
command line program.
separator
A character that is used to separate individual parts of the command line specified by cmdline. Normally a single space character is used but your program is free to choose a different character if this is more suitable.
Return Value
The function returns DV_RET_OK on success and a non-positive value on failure.
- const DV_RET_OK = 1 — success
Example 1
local cmdline = "zip C:\temp\archive.zip C:\temp\file1.txt C:\temp\file2.png"; local result = ::my.app.CmdLine(1, cmdline);
Example 2
local cmdline = "zip|C:\temp\archive.zip|C:\temp\file1.txt|C:\temp\file2.png"; local result = ::my.app.CmdLine(1, cmdline, '|');
Example 3
::my.app.SetHeaders("Content-Disposition: attachment; filename=\"archive.zip\"\r\n");
::my.app.Write("../private/files/archive.zip");
local cmdline = "{{PROG_ZIP}}|-d|{{CURR_OUTPUT}}|unused_file.txt";
local result = ::my.app.CmdLine(1, cmdline, '|');