473,657 Members | 2,426 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with exec

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);
echo("ReturnVal ue: ".$ReturnValue. "<br/>");

foreach($Output as $outputline)
{
echo("outputlin e: $outputline<br> ");
}
?>

But on my hosting server, I've installed (I believe) the properly
compiled version for that os, and it always returns 127. I don't have
shell access, so I'm a bit of loss on how to proceed. Any
information on this return code or how to work through this, would be
greatly appreciated.

Thanks, J
Nov 27 '07 #1
7 2200
JahMic wrote:
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);
echo("ReturnVal ue: ".$ReturnValue. "<br/>");

foreach($Output as $outputline)
{
echo("outputlin e: $outputline<br> ");
}
?>

But on my hosting server, I've installed (I believe) the properly
compiled version for that os, and it always returns 127. I don't have
shell access, so I'm a bit of loss on how to proceed. Any
information on this return code or how to work through this, would be
greatly appreciated.

Thanks, J
Hi J,

If you cannot execute in a shell, do a phpinfo(), and find the following
settings:

safe_mode = On or Off
and
safe_mode_exec_ dir =

Is safe_mode maybe On, and is your mask.exe not listed in
safe_mode_exec_ dir?

If so, you know why you cannot execute mask.exe.

Read more here: http://nl3.php.net/manual/en/function.phpinfo.php

Bottomline: Talk with your hosting provider. If they do not cooperate,
switch hosting provider or do not use mask.exe.

Regards,
Erwin Moller
Nov 27 '07 #2
On Nov 27, 7:14 pm, Erwin Moller
<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
JahMic wrote:
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);
echo("ReturnVal ue: ".$ReturnValue. "<br/>");
foreach($Output as $outputline)
{
echo("outputlin e: $outputline<br> ");
}
?>
But on my hosting server, I've installed (I believe) the properly
compiled version for that os, and it always returns 127. I don't have
shell access, so I'm a bit of loss on how to proceed. Any
information on this return code or how to work through this, would be
greatly appreciated.
Thanks, J

Hi J,

If you cannot execute in a shell, do a phpinfo(), and find the following
settings:

safe_mode = On or Off
and
safe_mode_exec_ dir =

Is safe_mode maybe On, and is your mask.exe not listed in
safe_mode_exec_ dir?

If so, you know why you cannot execute mask.exe.

Read more here:http://nl3.php.net/manual/en/function.phpinfo.php

Bottomline: Talk with your hosting provider. If they do not cooperate,
switch hosting provider or do not use mask.exe.

Regards,
Erwin Moller
Hi Erwin,

Thanks for the quick reply. safe mode is actually off. This
application is in the same directory as the scripts. If I change
$MaskData = "mask.exe -e \"TestString\"" ; to $MaskData = "./mask.exe -
e \"TestString\"" ; (the addition of ./) the value of $ReturnValue is 1
and no values for $Result and $output. (Output should be a long
string).

A hosting provider switch is likely, but this is an immediate issue
that I need to get taken care. Once again, any help is much
appreciated.

Thanks, J

Nov 27 '07 #3
JahMic wrote:
On Nov 27, 7:14 pm, Erwin Moller
<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
>JahMic wrote:
>>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("Resul t: ".$Result);
echo("ReturnV alue: ".$ReturnValue. "<br/>");
foreach($Outp ut as $outputline)
{
echo("outputlin e: $outputline<br> ");
}
?>
But on my hosting server, I've installed (I believe) the properly
compiled version for that os, and it always returns 127. I don't have
shell access, so I'm a bit of loss on how to proceed. Any
information on this return code or how to work through this, would be
greatly appreciated.
Thanks, J
Hi J,

If you cannot execute in a shell, do a phpinfo(), and find the following
settings:

safe_mode = On or Off
and
safe_mode_exec _dir =

Is safe_mode maybe On, and is your mask.exe not listed in
safe_mode_exec _dir?

If so, you know why you cannot execute mask.exe.

Read more here:http://nl3.php.net/manual/en/function.phpinfo.php

Bottomline: Talk with your hosting provider. If they do not cooperate,
switch hosting provider or do not use mask.exe.

Regards,
Erwin Moller

Hi Erwin,

Thanks for the quick reply. safe mode is actually off.
Good.

This
application is in the same directory as the scripts. If I change
$MaskData = "mask.exe -e \"TestString\"" ; to $MaskData = "./mask.exe -
e \"TestString\"" ; (the addition of ./) the value of $ReturnValue is 1
and no values for $Result and $output. (Output should be a long
string).
Ok, the $ReturnValue says 1, so I expect that the command DID run
succesfully.
Very strange your $Output array is empty.

Of course, what you want now is run the command by hand in a shell as
user PHP, being on Apache: Apache, or nobody or www-data, or
IUSR_<machinena meon IIS.

But you cannot.

So you'll have to debug by guessing.
Does the mask.exe has execution rights for PHP-user?
Do you maybe use files in mask.exe that are not accecible by PHP?
Throw in a full path to mask.exe instead of ./
Check your slashes, etc.
Try passthru() instead of exec().
And last but not least, insult the supportdepartme nt of your hosting
provider. ;-)

Good luck.

Regards,
Erwin Moller
A hosting provider switch is likely, but this is an immediate issue
that I need to get taken care. Once again, any help is much
appreciated.

Thanks, J
Nov 27 '07 #4
Hi Erwin, Once again thanks for the help. More comments below:

On Nov 27, 8:20 pm, Erwin Moller
<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
JahMic wrote:
On Nov 27, 7:14 pm, Erwin Moller
<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
JahMic wrote:
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);
echo("ReturnVa lue: ".$ReturnValue. "<br/>");
foreach($Outpu t as $outputline)
{
echo("outputlin e: $outputline<br> ");
}
?>
But on my hosting server, I've installed (I believe) the properly
compiled version for that os, and it always returns 127. I don't have
shell access, so I'm a bit of loss on how to proceed. Any
information on this return code or how to work through this, would be
greatly appreciated.
Thanks, J
Hi J,
If you cannot execute in a shell, do a phpinfo(), and find the following
settings:
safe_mode = On or Off
and
safe_mode_exec_ dir =
Is safe_mode maybe On, and is your mask.exe not listed in
safe_mode_exec_ dir?
If so, you know why you cannot execute mask.exe.
Read more here:http://nl3.php.net/manual/en/function.phpinfo.php
Bottomline: Talk with your hosting provider. If they do not cooperate,
switch hosting provider or do not use mask.exe.
Regards,
Erwin Moller
Hi Erwin,
Thanks for the quick reply. safe mode is actually off.

Good.

This
application is in the same directory as the scripts. If I change
$MaskData = "mask.exe -e \"TestString\"" ; to $MaskData = "./mask.exe -
e \"TestString\"" ; (the addition of ./) the value of $ReturnValue is 1
and no values for $Result and $output. (Output should be a long
string).

Ok, the $ReturnValue says 1, so I expect that the command DID run
succesfully.
Actually, on successful systems $ReturnValue is 0.
Very strange your $Output array is empty.
Is there a possible way to pipe or redirect the output?
>
Of course, what you want now is run the command by hand in a shell as
user PHP, being on Apache: Apache, or nobody or www-data, or
IUSR_<machinena meon IIS.

But you cannot.

So you'll have to debug by guessing.
Does the mask.exe has execution rights for PHP-user?
I've tried 777 to no avail.
Do you maybe use files in mask.exe that are not accecible by PHP?
No other files
Throw in a full path to mask.exe instead of ./
to no avail?
Check your slashes, etc.
Try passthru() instead of exec().
nada
And last but not least, insult the supportdepartme nt of your hosting
provider. ;-)
Don't worry about that, I'm giving them their due share of grieve.

Thanks, James
>
Good luck.

Regards,
Erwin Moller
A hosting provider switch is likely, but this is an immediate issue
that I need to get taken care. Once again, any help is much
appreciated.
Thanks, J- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Nov 28 '07 #5
JahMic wrote:

>>application is in the same directory as the scripts. If I change
$MaskData = "mask.exe -e \"TestString\"" ; to $MaskData = "./mask.exe -
e \"TestString\"" ; (the addition of ./) the value of $ReturnValue is 1
and no values for $Result and $output. (Output should be a long
string).
Ok, the $ReturnValue says 1, so I expect that the command DID run
succesfully.

Actually, on successful systems $ReturnValue is 0.
Oops. Sorry for the confusion.
>
>Very strange your $Output array is empty.

Is there a possible way to pipe or redirect the output?
Well, passthru() should do this.

<quote>
The passthru() function is similar to the exec() function in that it
executes a command . This function should be used in place of exec() or
system() when the output from the Unix command is binary data which
needs to be passed directly back to the browser. A common use for this
is to execute something like the pbmplus utilities that can output an
image stream directly. By setting the Content-type to image/gif and then
calling a pbmplus program to output a gif, you can create PHP scripts
that output images directly.
</quote>

>
>Of course, what you want now is run the command by hand in a shell as
user PHP, being on Apache: Apache, or nobody or www-data, or
IUSR_<machinen ameon IIS.

But you cannot.

So you'll have to debug by guessing.
Does the mask.exe has execution rights for PHP-user?

I've tried 777 to no avail.
clear.
>
>Do you maybe use files in mask.exe that are not accecible by PHP?

No other files
Anything else that might need additional rights?
Maybe opening ports under 1024 on *nix?

>
>Throw in a full path to mask.exe instead of ./

to no avail?
:-(
>
>Check your slashes, etc.
Try passthru() instead of exec().

nada
>And last but not least, insult the supportdepartme nt of your hosting
provider. ;-)

Don't worry about that, I'm giving them their due share of grieve.
Sorry James,

What you really need to do first is run the program from commandline to
see if it actually works.

You don't know for sure the program works. Is that right?

But I understand that is not possible, since you don't have shell. :-/
I think I would try the supportdepartme nt and ask then to try it for you.
Give them the command and ask them to run it for you.
If they refuse, shoot them. :P

It is very difficult to debug like this of course.
Sorry, I am also out of options.

Good luck!

Regards,
Erwin Moller
Thanks, James
>Good luck.

Regards,
Erwin Moller
>>A hosting provider switch is likely, but this is an immediate issue
that I need to get taken care. Once again, any help is much
appreciated .
Thanks, J- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -
Nov 28 '07 #6
On Nov 28, 5:37 am, Erwin Moller
<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
JahMic wrote:
>application is in the same directory as the scripts. If I change
$MaskData = "mask.exe -e \"TestString\"" ; to $MaskData = "./mask.exe -
e \"TestString\"" ; (the addition of ./) the value of $ReturnValue is 1
and no values for $Result and $output. (Output should be a long
string).
Ok, the $ReturnValue says 1, so I expect that the command DID run
succesfully.
Actually, on successful systems $ReturnValue is 0.

Oops. Sorry for the confusion.
Very strange your $Output array is empty.
Is there a possible way to pipe or redirect the output?

Well, passthru() should do this.

<quote>
The passthru() function is similar to the exec() function in that it
executes a command . This function should be used in place of exec() or
system() when the output from the Unix command is binary data which
needs to be passed directly back to the browser. A common use for this
is to execute something like the pbmplus utilities that can output an
image stream directly. By setting the Content-type to image/gif and then
calling a pbmplus program to output a gif, you can create PHP scripts
that output images directly.
</quote>
Of course, what you want now is run the command by hand in a shell as
user PHP, being on Apache: Apache, or nobody or www-data, or
IUSR_<machinena meon IIS.
But you cannot.
So you'll have to debug by guessing.
Does the mask.exe has execution rights for PHP-user?
I've tried 777 to no avail.

clear.
Do you maybe use files in mask.exe that are not accecible by PHP?
No other files

Anything else that might need additional rights?
Maybe opening ports under 1024 on *nix?
Throw in a full path to mask.exe instead of ./
to no avail?

:-(
Check your slashes, etc.
Try passthru() instead of exec().
nada
And last but not least, insult the supportdepartme nt of your hosting
provider. ;-)
Don't worry about that, I'm giving them their due share of grieve.

Sorry James,

What you really need to do first is run the program from commandline to
see if it actually works.

You don't know for sure the program works. Is that right?

But I understand that is not possible, since you don't have shell. :-/

I think I would try the supportdepartme nt and ask then to try it for you.
Give them the command and ask them to run it for you.
If they refuse, shoot them. :P

It is very difficult to debug like this of course.
Sorry, I am also out of options.

Good luck!

Regards,
Erwin Moller
Thanks, James
Good luck.
Regards,
Erwin Moller
>A hosting provider switch is likely, but this is an immediate issue
that I need to get taken care. Once again, any help is much
appreciated.
Thanks, J- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
What if you tried using exec to run the command but piping standard
out to one file and standard error to another file. Make sure both of
these files are in your home directory - and then use fopen to read
them. This probably won't help tooooo much but it might give you some
insight. Good luck!
Nov 29 '07 #7
On Nov 29, 9:13 pm, Aaron Saray <102degr...@102 degrees.comwrot e:
On Nov 28, 5:37 am, Erwin Moller

<Since_humans_r ead_this_I_am_s pammed_too_m... @spamyourself.c omwrote:
JahMicwrote:
>>application is in the same directory as the scripts. If I change
>>$MaskData = "mask.exe -e \"TestString\"" ; to $MaskData = "./mask.exe -
>>e \"TestString\"" ; (the addition of ./) the value of $ReturnValue is 1
>>and no values for $Result and $output. (Output should be a long
>>string).
>Ok, the $ReturnValue says 1, so I expect that the command DID run
>succesfully.
Actually, on successful systems $ReturnValue is 0.
Oops. Sorry for the confusion.
>Very strange your $Output array is empty.
Is there a possible way to pipe or redirect the output?
Well, passthru() should do this.
<quote>
The passthru() function is similar to the exec() function in that it
executes a command . This function should be used in place of exec() or
system() when the output from the Unix command is binary data which
needs to be passed directly back to the browser. A common use for this
is to execute something like the pbmplus utilities that can output an
image stream directly. By setting the Content-type to image/gif and then
calling a pbmplus program to output a gif, you can create PHP scripts
that output images directly.
</quote>
>Of course, what you want now is run the command by hand in a shell as
>user PHP, being on Apache: Apache, or nobody or www-data, or
>IUSR_<machinen ameon IIS.
>But you cannot.
>So you'll have to debug by guessing.
>Does the mask.exe has execution rights for PHP-user?
I've tried 777 to no avail.
clear.
>Do you maybe use files in mask.exe that are not accecible by PHP?
No other files
Anything else that might need additional rights?
Maybe opening ports under 1024 on *nix?
>Throw in a full path to mask.exe instead of ./
to no avail?
:-(
>Check your slashes, etc.
>Try passthru() instead of exec().
nada
>And last but not least, insult the supportdepartme nt of your hosting
>provider. ;-)
Don't worry about that, I'm giving them their due share of grieve.
Sorry James,
What you really need to do first is run the program from commandline to
see if it actually works.
You don't know for sure the program works. Is that right?
But I understand that is not possible, since you don't have shell. :-/
I think I would try the supportdepartme nt and ask then to try it for you.
Give them the command and ask them to run it for you.
If they refuse, shoot them. :P
It is very difficult to debug like this of course.
Sorry, I am also out of options.
Good luck!
Regards,
Erwin Moller
Thanks, James
>Good luck.
>Regards,
>Erwin Moller
>>A hosting provider switch is likely, but this is an immediate issue
>>that I need to get taken care. Once again, any help is much
>>appreciated .
>>Thanks, J- Hide quoted text -
>- Show quoted text -- Hide quoted text -
>- Show quoted text -

What if you tried using exec to run the command but piping standard
out to one file and standard error to another file. Make sure both of
these files are in your home directory - and then use fopen to read
them. This probably won't help tooooo much but it might give you some
insight. Good luck!- Hide quoted text -

- Show quoted text -
As it turns out, after blindly switching binaries, I found out I was
trying to use a binary for a different OS. (too many flavors of unix)
Of course, if I had shell access, I could have found this out in 5
minutes. Onwards to other problems.

Many thanks for all the help,

J
Dec 1 '07 #8

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

Similar topics

3
5101
by: starlightjen | last post by:
Hello, I'm trying to use php to update my htpasswd file. I have my permissions on .htpasswd set to 777, so it should be wide open. From the command line (when logged into the server as "nobody", my server's web user) I can get the htpasswd.exe to run without a problem, but when passed through my php exec() function the .htpasswd file does not change. I'm not getting any errors, but I'm not getting any action either.
6
8379
by: Hal Vaughan | last post by:
I have a script used to find and run Java on a Windows system.  It worked fine on original tests (on a Windows XP system).  It's now running on a Windows 2000 (sp3) system, and it won't work -- the problem is this line: set oCommand = WshShl.Exec(sCommand) (it's about halfway down)  Is there a problem with the Exec method in some versions of VBS?  Is the problem Windows version I'm on, or is it something more obvious that I'm just not...
1
5069
by: Hal Vaughan | last post by:
I've been using Runtime.exec() like this: Runtime rt = Runtime.getRuntime(); try {Process p = rt.exec("MyCommand.bat");} catch (Exception e) {do stuff} When I start my Java classes, I start them with a batch file that changes to my apps home directory. I've tried exec() with a full pathname (which seems to have problems on Windows if it has spaces in it, but I'm not sure if that's really the problem), with just the simple short batch...
1
2225
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--
17
7911
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
0
2689
by: Christian Rank | last post by:
Today I ran into problems when combining a C program with SQL statements with the ECPG interface of PostgreSQL: According to the documentation, it should be possible with EXEC SQL WHENEVER NOT FOUND action to trigger an action when a query does not return a row. This does not seem to function. Here is the C program I tested: ----------------------------------------------------------------
4
2357
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of which I mean here. Just for a moment, let's just take one definition for one of the
26
3641
by: warth33 | last post by:
Hello I have a php site. Some page needs to call an external program. The programs are home made c# applications. It uses to work without problem. For a while. Maybe it work for some hour. Or for a day. Or even for a week. At a certain point, when a php script calls the exe file, the application freezes. The following happens:
23
9370
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
8315
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
8734
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...
0
8608
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
7341
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
6172
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
5633
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
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.