473,405 Members | 2,294 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,405 software developers and data experts.

exec returns -1

I've narrowed the code to a problem with php/iplanet on linux. When I
run the following code from the command line "$status" comes back as
"0" as it should. However when I hit it with a browser, status is "-1".
Im guessing it has something to do with the way iplanet is invoking
php, or how php was compiled. Oddly enough I have the same setup
running on windows with php 4&5 and it always returns "0". Lucky for me
I suppose... Anyone know how to fix this? Is it as simple as
recompiling with additional options?

You can view my results here: http://www.69camaro.us/test/go.php

OS: fedora C4
PHP: 4.4.2
Iplanet: 6.1 sp5

<?php

$command='echo "hello world"';
$results = array();
$Output = exec($command, $results, $status);

print " Output: $Output<br><br>";
print "command: $command <br>";
print "results: $results <br>";
print " status: $status <br>";

?>

Apr 16 '06 #1
13 4590
d
"inetquestion" <in**********@hotmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
I've narrowed the code to a problem with php/iplanet on linux. When I
run the following code from the command line "$status" comes back as
"0" as it should. However when I hit it with a browser, status is "-1".
Im guessing it has something to do with the way iplanet is invoking
php, or how php was compiled. Oddly enough I have the same setup
running on windows with php 4&5 and it always returns "0". Lucky for me
I suppose... Anyone know how to fix this? Is it as simple as
recompiling with additional options?

You can view my results here: http://www.69camaro.us/test/go.php

OS: fedora C4
PHP: 4.4.2
Iplanet: 6.1 sp5

<?php

$command='echo "hello world"';
$results = array();
$Output = exec($command, $results, $status);

print " Output: $Output<br><br>";
print "command: $command <br>";
print "results: $results <br>";
print " status: $status <br>";

?>


There is no reason to use eval. It's evil.

"If eval is the answer, you're asking the wrong question"
Apr 16 '06 #2
d wrote:
"inetquestion" <in**********@hotmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
I've narrowed the code to a problem with php/iplanet on linux. When I
run the following code from the command line "$status" comes back as
"0" as it should. However when I hit it with a browser, status is "-1".
Im guessing it has something to do with the way iplanet is invoking
php, or how php was compiled. Oddly enough I have the same setup
running on windows with php 4&5 and it always returns "0". Lucky for me
I suppose... Anyone know how to fix this? Is it as simple as
recompiling with additional options?

You can view my results here: http://www.69camaro.us/test/go.php

OS: fedora C4
PHP: 4.4.2
Iplanet: 6.1 sp5

<?php

$command='echo "hello world"';
$results = array();
$Output = exec($command, $results, $status);

print " Output: $Output<br><br>";
print "command: $command <br>";
print "results: $results <br>";
print " status: $status <br>";

?>

There is no reason to use eval. It's evil.

"If eval is the answer, you're asking the wrong question"


I don't see anyone using eval here.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 16 '06 #3
inetquestion wrote:
I've narrowed the code to a problem with php/iplanet on linux. When I
run the following code from the command line "$status" comes back as
"0" as it should. However when I hit it with a browser, status is "-1".
Im guessing it has something to do with the way iplanet is invoking
php, or how php was compiled. Oddly enough I have the same setup
running on windows with php 4&5 and it always returns "0". Lucky for me
I suppose... Anyone know how to fix this? Is it as simple as
recompiling with additional options?

You can view my results here: http://www.69camaro.us/test/go.php

OS: fedora C4
PHP: 4.4.2
Iplanet: 6.1 sp5

<?php

$command='echo "hello world"';
$results = array();
$Output = exec($command, $results, $status);

print " Output: $Output<br><br>";
print "command: $command <br>";
print "results: $results <br>";
print " status: $status <br>";

?>


I'd suggest it's probably a permissions problem. Anything in your error logs?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 16 '06 #4
The echo actually suceeds, so there are no errors associated with
running this command or loading the page.

Apr 16 '06 #5
ok, not sure what you mean about eval since its nowhere in the code I
posted. However this example is similar to a function that is failing
when I try to enable Imagemagick in gallery 2.2 & 2.1. Since the
gallery folks do not support Iplanet I'm more or less left to my own
devices to breakdown the code and find the core problem, which is what
I've done here. Unfortunately I've broken it down as far as I can for
now...hence the post here.

Apr 16 '06 #6
d
"Jerry Stuckle" <js*******@attglobal.net> wrote in message
news:MM******************************@comcast.com. ..
d wrote:
"inetquestion" <in**********@hotmail.com> wrote in message
news:11**********************@v46g2000cwv.googlegr oups.com...
I've narrowed the code to a problem with php/iplanet on linux. When I
run the following code from the command line "$status" comes back as
"0" as it should. However when I hit it with a browser, status is "-1".
Im guessing it has something to do with the way iplanet is invoking
php, or how php was compiled. Oddly enough I have the same setup
running on windows with php 4&5 and it always returns "0". Lucky for me
I suppose... Anyone know how to fix this? Is it as simple as
recompiling with additional options?

You can view my results here: http://www.69camaro.us/test/go.php

OS: fedora C4
PHP: 4.4.2
Iplanet: 6.1 sp5

<?php

$command='echo "hello world"';
$results = array();
$Output = exec($command, $results, $status);

print " Output: $Output<br><br>";
print "command: $command <br>";
print "results: $results <br>";
print " status: $status <br>";

?>

There is no reason to use eval. It's evil.

"If eval is the answer, you're asking the wrong question"


I don't see anyone using eval here.


that's what I get when I post after having a few beers :)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Apr 16 '06 #7
>I've narrowed the code to a problem with php/iplanet on linux. When I
run the following code from the command line "$status" comes back as
"0" as it should. However when I hit it with a browser, status is "-1".
Im guessing it has something to do with the way iplanet is invoking
php, or how php was compiled. Oddly enough I have the same setup
running on windows with php 4&5 and it always returns "0". Lucky for me
I suppose... Anyone know how to fix this? Is it as simple as
recompiling with additional options?


Where is the executable for the "echo" command? (answer for both
setups). Is the directory the executable for the "echo" command
is in listed in $PATH (answer for both setups)? Is safe mode on,
and if so, is the executable for "echo" present in a directory
listed in safe_mode_exec_dir (answer for both setups)?

Note that I don't see anything in the description of exec() that
says you can use shell builtin commands (just as you can't on the
C exec() function).

Gordon L. Burditt
Apr 16 '06 #8
Checked and the 'echo' binary is in /bin/echo. The PATH for a user
ssh'd in and that of a script being executed by the browser both
include "/bin", so there is no issue from that perspective. This can
also be confirmed that it is working from the output below. Since it
sucessfully produces the string "hello world". The echo command is
working, however the result code which exec is setting is always set to
-1 when the script is invoked by the webserver. This is true even if
the command you are trying to run is invalid or does not exist. If I
run the same script with an invalid command from the command line, the
exec function in this scenario gives a status of 127.

This is the output from hitting this script on a webserver with a
browser:
#######################
Output: hello world

command: echo "hello world"
results: Array
status: -1
#######################

This is the output from hitting this script through an ssh session and
running "php go.php"
#######################
Output: hello world<br><br>command: echo "hello world" <br>results:
Array <br> status: 0 <br>
#######################

Apr 17 '06 #9
Does php need to be compiled with a special option for use on
iplanet/sunone webservers on linux for the exec function to work
properly?

Apr 18 '06 #10
inetquestion wrote:
Does php need to be compiled with a special option for use on
iplanet/sunone webservers on linux for the exec function to work
properly?


They may have safe_mode on or exec() disabled. What does phpinfo() say?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 18 '06 #11
I think they are off, but you can see the output here:

http://www.69camaro.us/test

Apr 18 '06 #12
inetquestion wrote:
I think they are off, but you can see the output here:

http://www.69camaro.us/test


Ah, I missed the fact you're using Sun.

It has some security features in it, also. I've never used it, but I've heard
of people who have problems with it.

Maybe someone familiar with it can hop in here.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 18 '06 #13
Any other iplanet/php peeps out there?

Apr 29 '06 #14

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

Similar topics

3
by: Paolo Scolamacchia | last post by:
Hi everybody, this is my environment : Apache is installed on a Linux server (RedHat9A) and I launch the browser on a PC running WindowsXP to execute php scripts on the Linux server. I would run...
4
by: Andrew Crowe | last post by:
Hi guys, I'm having trouble executing commands using exec() or system() that need to write files. I've set the permissions on CMD.EXE but I can't use exec() to write any files, even if the...
2
by: Jonathan | last post by:
I'm puzzled by Python's behavior when binding local variables which are introduced within exec() or execfile() statements. First, consider this simple Python program: # main.py def f() : x = 1...
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"...
1
by: Crazy Cat | last post by:
Hi, whenever the underlying query being called by EXEC in the following has an empty result set I get the following error -- Invalid Data for 'Numeric' when EXEC returns empty row. However if I...
2
by: Uldis Bojars | last post by:
Hi All, I have encountered problems with JS RegExp.exec() and can't find what is the problem. Could you help me? formRequest is a function that extracts some information from XMLHTTPRequest...
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)
26
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....
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...
0
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...

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.