473,387 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

exec hide dos box

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;
}
Mar 6 '07 #1
2 5448
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.
js*******@attglobal.net
==================
Mar 6 '07 #2
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.
Ok, thank you for the answer.

Best regards,
-Hendri.
Mar 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andr? Roberge | last post by:
I have the following two files: #--testexec.py-- def exec_code(co): try: exec co except: print "error" #-- test.py--
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
17
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
5
by: TPJ | last post by:
I have the following code: ----------------------------------- def f(): def g(): a = 'a' # marked line 1 exec 'a = "b"' in globals(), locals() print "g: a =", a
2
by: xml0x1a | last post by:
How do I use exec? Python 2.4.3 ---- from math import * G = 1 def d(): L = 1 exec "def f(x): return L + log(G) " in globals(), locals() f(1)
7
by: JahMic | last post by:
I'm having a problem with exec on my hosting server. Unfortunately, the hosting support seems to be anything but helpful. The following works fine on my localhost: <?php $MaskData =...
23
by: Maarten | last post by:
Howdy, Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and I have a little problem with one function within my cd-management script. For extracting a bit of info from my...
0
by: Stef Mientki | last post by:
hello, I've syntax error which I totally don't understand: ########## mainfile : import test_upframe2 if __name__ == '__main__': var1 = 33 code = 'print var1 + 3 \n'
0
by: Terry Reedy | last post by:
Stef Mientki wrote: Indendation is screwed. Is the above all do_more body? Which locals does this get you? __init__'s? (locals()?) Isn't this just the same as globals()?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.