Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay, this is where I've gotten to so far. I figured I don't need a dynamic batch file, I can just supply args (duh). So I can just call <code>exec("start Batch.bat log.txt stdout.txt c:\my.exe a b c");</code> and monitor the log files with some ajax (as I do now)</p> <pre><code>REM first 2 params are log filenames set LogFilename=%1 shift set StdOutFilename=%1 shift REM Code to concatonate all following params from here REM http://stackoverflow.com/questions/761615/is-there-a-way-to-indicate-the-last-n-parameters-in-a-batch-file set params=%1 :loop shift if [%1]==[] goto afterloop set params=%params% %1 goto loop :afterloop REM command line is everything after the log-filename param set CommandLine=%params% @echo log: %LogFilename% @echo stdout: %StdOutFilename% @echo command: %CommandLine% if ["%LogFilename%"]==[] exit 255; if ["%StdOutFilename%"]==[] exit 254; if ["%CommandLine%"]==[] exit 253; REM execute command hidden(/B), wait for it to finish so we can get the return code (/WAIT) and output to stdlog @start /B /WAIT %CommandLine% &gt;&gt; %StdOutFilename% REM log return code "RET X" @echo RET %ERRORLEVEL% &gt;&gt; %LogFilename% </code></pre> <p>And the calling PHP code;</p> <pre><code>$BatchCommandLine = "start /D $Cwd /B /WAIT execute.bat $LogName %StdLogName $Exe $Params"; $OutputLine = exec( $BatchCommandLine, $Output, $ReturnCode ); if ( $ReturnCode != 0 ) echo "Batch file failed to execute"; </code></pre> <p>*<em>EDIT: *</em> Oops, exec() doesn't launch in the background even with start. Still, solved my other problems...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload