468,249 Members | 1,470 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

exec() gives only 127 back

Hi,

I've got the following problem: exec() and shell_exec(), etc. don't give
anything back, just the error code 127 (command not found?!)

For example, the following script:

<?php
exec("cat ./test", $lines, $result);

// or exec("./cat ./test", $lines, $result);
echo "result = $result<br>";
echo "Lines<br>\n";
foreach ($lines as $k => $v) {
echo "k=$k v=$v<br>\n";
}
?>

causes on my homeserver just

result = 127
Lines
whereas the provider's server makes it the right way:

result = 0
Lines
k=0 v=msdflkdsfkldffdf
k=1 v=fdfdlkmdfklfdkflfd
k=2 v=fdfldkkfdklfdlkfdlkfdlkfd
k=3 v=fdfdkfdklfdklfklfdlkdffd
k=4 v=fdfkfdkldfkjdflkfdklfdlkfdf
k=5 v=dfdkldflfdkkdflkflk

System: Debian / Apache 2.0 + PHP 4.3.2 as module

what's wrong?

thanks
Jul 17 '05 #1
5 8626
[ X-Newsreader: Microsoft Outlook Express 5.50.4927.1200 ]
_______________^^^^^^^^^^^^^^^^^^^^^^^^^^^________ ________

PeterF wrote:
I've got the following problem: exec() and shell_exec(), etc. don't give
anything back, just the error code 127 (command not found?!)

For example, the following script:

<?php
exec("cat ./test", $lines, $result);
Do you have a executable file named cat in a directory that's part of
your path?

Open a DOS Prompt window and type "cat autoexec.bat"

After that fails try "type autoexec.bat"

Try

$lastline = exec('type ./test', $lines, $result);
// add last line of output to the $lines array
$lines[] = $lastline;

System: Debian / Apache 2.0 + PHP 4.3.2 as module This is the host, right?
what's wrong?

Windows is wrong :) -- SCNR
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
huh,

type autoexec.bat?? sorry but I'm working with a Debian webserver

Do you have a executable file named cat in a directory that's part of
your path?


yes

thanks
Jul 17 '05 #3
PeterF <NO*************@pf-webservices.de> wrote:
Hi,

I've got the following problem: exec() and shell_exec(), etc. don't give
anything back, just the error code 127 (command not found?!)

For example, the following script:

<?php
exec("cat ./test", $lines, $result);


- have you tried '/bin/cat' (or wherever your cat is, do 'which cat' to
find that out) instead of just 'cat'?
- do other shell commands work?
- or is your web server perhaps chrooted in its own directory? in this
case it won't be able to access /bin/cat or anything else outside the
chroot.

steven
Jul 17 '05 #4
PeterF wrote:
huh,

type autoexec.bat?? sorry but I'm working with a Debian webserver


Oops ... I was led astray because of your User-Agent, sorry.

Do you have safe_mode on?
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #5
No, safe_mode is off :(
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Jerry | last post: by
14 posts views Thread by Hemanth | last post: by
5 posts views Thread by Carlos Ribeiro | last post: by
1 post views Thread by kurt.krueckeberg | last post: by
26 posts views Thread by warth33 | last post: by
23 posts views Thread by Maarten | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.