472,805 Members | 906 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

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 8896
[ 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jerry | last post by:
I've found a problem with exec, passthru, shell_exec & system. I'm trying to run the following exec("sort -r -n -k2,2 r1.txt > r2.txt") with r1.txt being a numeric file. The file looks like...
14
by: Hemanth | last post by:
Hello there, I'm new to PHP. I'm trying to run a simple php script (on a Red hat linux machine with apache web server ) through a windows web browser (IE). I'm using an exec() function in my...
5
by: Carlos Ribeiro | last post by:
Hello all, I have a module that retrieves code snippets from a database to be executed on the fly . As I make heavy use of accented characters inside strings (I'm in Brazil), it came to my...
1
by: kurt.krueckeberg | last post by:
The second line of this script <?php // current directory echo getcwd() . "<br />"; print ( exec("ls *.*") ); ?> should display the names of the four files (it does in an ssh session) which...
4
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...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
5
by: jmuria | last post by:
Hi. I'm trying to make a web page to work. It worked before so it has to be something related with the configuration. My problem is a call to a compiled executable (made for me) that returns 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: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.