This function executes an external program. The parameter s_timeout is evaluated temporary only under Win9x / WinNT. The call program is executed completely before it returns the control to the CGI program. The called programm gets the input and output streams of the CGI program. That is why the output buffering should be turned off before the execution (as the external program can not write in the buffer of the tdbengine).
Particularities Win9x, WinNT:
The program is started directly. With s_timeout the maximum available time (in seconds) can be specified. Is the program terminated abortifly, the function value is -1. Is s_timeout set to -1, the programm is excuted completely, but the output is eliminated. This strategy is in any case preferable to output redirection. The rights of the executed program are deduced from the rights of the internet client.
Example:
correct: (pkzip25.exe is located in /home/tdbengine/)
CGICloseBuffer .. empty buffer
CGIExec('pkzip25.exe -add backup.zip *') .. shows the whole list
.. and creates backup.zip in the CGI directory
correct: (cmd.exe is located in /home/tdbengine/)
...
CGIExec('cmd.exe /c set') .. shows the whole environment
wrong: (cmd.exe and pkzip25 are located in /home/tdbengine/)
...
CGIExe('cmd.exe /c pkzip25.exe -add backup.zip * > nul') .. creates backup.zip without output
correct: (pkzip25.exe is located in /home/tdbengine/)
CGIExec('pkzip25.exe -add backup.zip *',-1) .. creates backup.zip without output
Restriction: CGIExec can execute (at least trouble-free) only real 32 bit applications.
Linux:
The commandline of CGIEexc is committed to the Shell of the internet client with its rights. Information: Here the output redirection is the recommended way, to suppress the output of the called program.
Example:
CGICloseBuffer .. clear buffer
CGIWrite('') .. output according to screen
CGIExec('set') .. shows the whole environment
CGIWriteLn(' ')..CGIExec('tar -cz -fbackup.tar.gz *') .. creates the archive backup.tar.gz with output....CGIExec('tar -cz -fbackup.tar.gz * > /dev/null') .. creates the archive backup.tar.gz without output.. Information: You should use CGIExec always with special caution. Scotch with suitable semaphores simultaneous calls (above all at archiving programs). Consider that every CGI process has only limited disposable time (adjustable in the http server).
|