473,748 Members | 2,471 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

shell_exec not working on Win2K3

Hi all,

We have PHP 4 installed on Windows 2003 with Apache 2, and the
shell_exec has mysteriously stopped working - it hangs the page rather
then returning anything.

To check it out, I tried shell_exec("dir ") which works fine on the
development machine, but not on the live server.

I'm guessing the network guys have done something to the security of
the live server that would cause this - but it's very strange; why
would Apache (running under the default system account) not allow PHP
to run shell_exec statements?

I have checked PHP and it's not in safe mode.

I'm a bit stuck - any ideas would be appreciated...

Feb 3 '06 #1
6 5620
d
"jonathan.becke tt" <jo************ **@gmail.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
Hi all,

We have PHP 4 installed on Windows 2003 with Apache 2, and the
shell_exec has mysteriously stopped working - it hangs the page rather
then returning anything.

To check it out, I tried shell_exec("dir ") which works fine on the
development machine, but not on the live server.

I'm guessing the network guys have done something to the security of
the live server that would cause this - but it's very strange; why
would Apache (running under the default system account) not allow PHP
to run shell_exec statements?

I have checked PHP and it's not in safe mode.

I'm a bit stuck - any ideas would be appreciated...


Have you checked the permissions of the cmd.exe file in windows\system3 2?
It has to be executable by the user the web server is running as... Usually
that will return an error, though, so it might not be the cause of your
problem... :)

dave
Feb 3 '06 #2
Nope - I just simulated that on the test server, and it doesn't hang
the pages... it just returns nothing.

The behaviour we are getting on the live server is that any page using
shell_exec hangs the page - the browser just sits with the sand timer
indefinitely...

I'm still waiting for somebody to grab the apache logs for me -
hopefully they will explain what is going on.

If anybody else has any ideas I'd love to know.

Feb 3 '06 #3
jonathan.becket t wrote:
Hi all,

We have PHP 4 installed on Windows 2003 with Apache 2, and the
shell_exec has mysteriously stopped working - it hangs the page rather
then returning anything.

To check it out, I tried shell_exec("dir ") which works fine on the
development machine, but not on the live server.

I'm guessing the network guys have done something to the security of
the live server that would cause this - but it's very strange; why
would Apache (running under the default system account) not allow PHP
to run shell_exec statements?

I have checked PHP and it's not in safe mode.

I'm a bit stuck - any ideas would be appreciated...


Hi,

Did you read the usercontributio ns on php.net?
Maybe they contain a few hints.
They can be found here:

http://nl2.php.net/manual/en/function.shell-exec.php

For example: Somebody complained that the systemcall didn't return. Turned
out to be memorylimit for PHP wasn't enough for the command to complete
succesfully.

Read them, maybe you find something that is usefull.

If that doesn't help: Please provide us with more information, like what you
are calling, etc. etc.

Regards,
Erwin Moller
Feb 3 '06 #4
Yep - I've already read the PHP website (it was the first place I
looked after we found out shell_exec was misbehaving).

Some background would probably help - the script call worked before the
server was locked down and put in the DMZ for public access.

Following that, the script call didn't work any more. I have stuck a
test script on the server just calling shell_exec("dir "); and it's
hanging... on my test box if I remove permissions on cmd.exe, it just
returns an empty string (i.e. what you would expect).

I'm still waiting for the apache logs - hopefully they will provide
some more meaningful information...

Feb 3 '06 #5
jonathan.becket t wrote:
Yep - I've already read the PHP website (it was the first place I
looked after we found out shell_exec was misbehaving).
Ok, good. :-)

Some background would probably help - the script call worked before the
server was locked down and put in the DMZ for public access.
Hmm, maybe your call to the program needs some network-access that is now
blocked because of new location (DMZ)?


Following that, the script call didn't work any more. I have stuck a
test script on the server just calling shell_exec("dir "); and it's
hanging... on my test box if I remove permissions on cmd.exe, it just
returns an empty string (i.e. what you would expect).
Aha, so it has nothing to do with DMZ-blocked networkaccess.
If even 'dir' doesn't return...


I'm still waiting for the apache logs - hopefully they will provide
some more meaningful information...


Did you turn on errorreporting to ALL?
Or doesn't that help because the script just times-out?

Well, I am out of ideas as you can see. :-/

Let us know what you find (with apachelogs maybe), and please: if you fix
it: tell us all how on php.net. :-)

Good luck,
Erwin Moller

Feb 3 '06 #6
"jonathan.becke tt" <jo************ **@gmail.com> wrote in
news:11******** *************@o 13g2000cwo.goog legroups.com:
Hi all,

We have PHP 4 installed on Windows 2003 with Apache 2, and the
shell_exec has mysteriously stopped working - it hangs the page rather
then returning anything.


hi

try using backticks:

ln 1:$myCommand = "some code that will do things on the server";
ln 2:`$myCommand`;

instead of
ln 2:shell_exec($m yCommand);
the backtick thing has worked for me in all instances where shell_exec,
exec have not.

Feb 3 '06 #7

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

Similar topics

0
1577
by: Sandman | last post by:
In another post I told about PHP not being able to create dates earlier than 1970, so until I can get PHP to do so, I am using a small perlscript to do it. It looks like this: // $in is something like "1943-10-12"; $unixtime = shell_exec("bin/converttime.pl $in"); Problem is, this fails once ever twenty times or so - shell_exec() doesn't return anything. This is true of another place where I use shell_exec() to run
1
5959
by: Steve | last post by:
Hi, I'm trying to 'ssh' into another machine, run a small script and fetch it's output, using shell_exec(). The problem is, it takes AGES to run ssh and I don't know what's happening. If I try 'ssh'ing manually on the shell, it takes a microsecond to fetch the result, whereas shell_exec takes very very long and I don't know how to debug the problem. That's problem number one: How do I tell what's happening and why is it taking so long?
8
6267
by: Good Man | last post by:
Hi there If I enter the following at the command line, I successfully get an email sent to the correct name/email: php /var/www/html/admin/adminscripts/welcome-cli.php 'Me' 'me@me.net'
2
3156
by: bgeneto | last post by:
Can't get these commands to work! The following page simply doesn't finish loading ( Waiting... Opening... :-( ) <?php echo system("dir"); ?> The same for <?php echo exec("dir"); ?> or <?php echo shell_exec("dir"); ?>, etc... I'm running Apache 2.0.55 & PHP 5.0.5 with Zend Optimizer v2.5.10 on windows XP SP2. Any help is welcome,
4
1143
by: SoCalGuy | last post by:
Hi all, I have a .net web app written in C# (.net 1.1). It has worked just great being served from xp pro (dev) and Win2k (prod), for the last 6 months. We have recently moved it to a brand new install of Win2k3. All I did was create a new web on my Win2k3 server and copy my directory over (that's how I have moved in the past). Now some buttons don't do anything (others are working okay and most of the app is just fine). You just...
0
1337
by: Don | last post by:
Hi, I have a problem with the special characters on the function shell_exec (under Linux Debian with php 4.3.10-16): $msg = '"'."Léà t'es où?".'"'; $output = shell_exec('java myClass'.' '.$msg); All the special characters in $msg like é or à are turned into the
3
3462
by: Paul F. Johnson | last post by:
Hi, I'm trying to create a zip file from some pdfs and have code similar to this $id=$_GET; $fn = array("a", "b", "c", "d"); chdir('../downloads'); // the php file is in /php $files = $fn."1.pdf ".$fn."2.pdf 7-17.pdf"; $command = "zip -9 " . $fn . ".zip " . $files; header("content-type:application/zip");
0
1160
by: Akkad | last post by:
hi, i am having problem using shell_exec() function: <code> shell_exec("cat `find ./logs -name access.log*` | grep akadi_icho | ./calamaris/calamaris -a -P 60 -T 0 -r 400 -d 500 -u -O -w > akadi_icho.html"); </code> i am not getting the ouput file, though the command string passed in the function is working perfectly when used on the shell. but when i am trying to execute it using this function in a php file, no ouput file is made. so...
1
2543
by: itskaps | last post by:
Hi all, My following program code works fine on win 2K server but the same is not working on win2K3 server. It's showing error as page cannot be displayed. After debugging, I found that fso.opentextfile is not working over win2k3. Can anybody pl. explain why it's not working and how to solve it? help reqd urgently pl. thx in advance. SearchDatabase <SCRIPT LANGUAGE=JScript>
0
8823
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
9530
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9363
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
9312
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,...
1
6793
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
6073
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
4593
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...
2
2775
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.