473,779 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_nam e.'" "'.$tmp_old_nam e.'"');

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.e xe -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.Sh ell");

// Make the command window but dont show it.
$oExec = $WshShell->Run($cmdline , 0, $m);

if ($outputfile){
// Read the tmp file.
$retStr = file_get_conten ts($outputfile) ;
// Delete the temp_file.
#unlink($output file);
}
else $retStr = "";

return $retStr;
}
Mar 6 '07 #1
2 5465
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_nam e.'" "'.$tmp_old_nam e.'"');

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.e xe -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.Sh ell");

// Make the command window but dont show it.
$oExec = $WshShell->Run($cmdline , 0, $m);

if ($outputfile){
// Read the tmp file.
$retStr = file_get_conten ts($outputfile) ;
// Delete the temp_file.
#unlink($output file);
}
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*******@attgl obal.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
2230
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
10212
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 database table, using dynamic sql. Executing 'EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;' the error code -2149 is returned That means "Specified partition does not exist". Does anybody know if it is a database problem or a problem of
17
7925
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" requires user input to run; this causes the TCL script calling the PHP script to hose up and die. Is there a way I can do this so that the TCL script can call the PHP
5
2436
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
3110
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
2209
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 = "mask.exe -e \"TestString\""; $Result = exec($MaskData, $Output, $ReturnValue); echo("Result: ".$Result);
23
9389
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 cd's I have an executable which I execute with exec(): $discOutput = exec('./discid /dev/rdisk2');
0
1786
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
3010
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
9632
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7478
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.