|
Posted by Jerry Stuckle on 03/06/07 11:42
Hendri Adriaens wrote:
> Hi,
>
> I succeeded in finding a workaround for the quotation bug in exec that
> caused an error in the apache error logs. here it is:
> exec('start "zip" /B "'.$winzip_path.'\wzzip" -m -s'.$password.'
> "'.$tmp_new_name.'" "'.$tmp_old_name.'"');
>
> But unfortunately, the /B switch doesn't do it's job, I still see the dos
> box. Is there a way to suppress it?
>
> I found the script that is posted below, but that doesn't wait for winzip to
> finish. Is there any solution that I can run winzip without a dos box and
> that php waits for winzip to finish?
>
> Thank you, best regards,
> -Hendri.
>
> function windExec($cmd,$mode=''){
> // runs a command line and returns
> // the output even for Wind XP SP2
> // example: $cmd = "fullpath.exe -arg1 -arg2"
> // $outputString = windExec($cmd, "FG");
> // OR windExec($cmd);
> // (no output since it runs in BG by default)
> // for output requires that EXEC_TMP_DIR be defined
>
> // Setup the command to run from "run"
> $cmdline = "cmd /C $cmd";
>
> // set-up the output and mode
> if ($mode=='FG'){
> $outputfile = EXEC_TMP_DIR . "\\" . time() . ".txt";
> $cmdline .= " > $outputfile";
> $m = true;
> }
> else $m = false;
>
> // Make a new instance of the COM object
> $WshShell = new COM("WScript.Shell");
>
> // Make the command window but dont show it.
> $oExec = $WshShell->Run($cmdline, 0, $m);
>
> if ($outputfile){
> // Read the tmp file.
> $retStr = file_get_contents($outputfile);
> // Delete the temp_file.
> #unlink($outputfile);
> }
> else $retStr = "";
>
> return $retStr;
> }
>
>
It's opening a command line prompt because you can't run a command line
program in a windowed session - at least not without some workarounds.
What you're running into is Windows limitations, not PHP. I'd recommend
you ask in a Windows newsgroup. Maybe they have some ideas - i.e. other
COM objects you could use.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|