can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who
and other, however i can not execute C programms and i really don't know
why.
Please help me,
Peter 17 2389
Piotr Wolski wrote: can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why.
Please help me, Peter
what do you think ls, who, and others are written in?? What are you trying do
do? does the webserver user have access to said "c" program? do you have the
correct privs set on the files? What OS? does the program take parameters, if
so, show us the code of how you are executing them. Have you read the docs
carefully and seen the examples given there??
--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
On Mon, 12 Jul 2004 13:49:21 -0500, Piotr Wolski <wo****@cs.purdue.edu> wrote: can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why.
Neither do I. Post some details. 'ls' and 'who' are both C programs, not that
it actually matters what they're originally written in.
Odds are it's a permissions problem of some sort.
--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Michael Austin wrote: Piotr Wolski wrote:
can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why.
Please help me, Peter
what do you think ls, who, and others are written in?? What are you trying do do? does the webserver user have access to said "c" program? do you have the correct privs set on the files? What OS? does the program take parameters, if so, show us the code of how you are executing them. Have you read the docs carefully and seen the examples given there??
ok ls and others are written in C however they are included as system
programms(commands). My C programms compiled ,executes perfectly from
command line, however they cannot be executed from the web. unix system.
it doesn't matter if the programms takes or doesn't take parameters. I'm
trying the simplest C programm that should write out few letters. i even
added compiled programm to the PATH directory. and the result is the same..
i'm trying to do so:
exec("progs");
or passthru("progs");
even when i add all the path it doesn't take any result.
i tried exec("./progs 2> error_file");
when compiled programm is in the directory where the script is, then the
error_file looks like:
../progs: syntax error at line 1: '(' unexpected
what the hell does it mean??
../progs exectuted from command line does what he should do very good..
please for help
Andy Hassall wrote: On Mon, 12 Jul 2004 13:49:21 -0500, Piotr Wolski <wo****@cs.purdue.edu> wrote:
can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why.
Neither do I. Post some details. 'ls' and 'who' are both C programs, not that it actually matters what they're originally written in.
Odds are it's a permissions problem of some sort.
i changed permissions to my compiled C programms: +rwx and nothing changed:(
Piotr Wolski wrote: can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why.
What do you mean, "can not execute"? Do you receive a PHP error message?
A system error message? No error, just doesn't see to run?
Details details details.
Brian Rodenborn
Piotr Wolski wrote: i'm trying to do so: exec("progs"); or passthru("progs"); even when i add all the path it doesn't take any result. i tried exec("./progs 2> error_file"); when compiled programm is in the directory where the script is, then the error_file looks like: ./progs: syntax error at line 1: '(' unexpected what the hell does it mean?? ./progs exectuted from command line does what he should do very good..
does the webserver know where .progs lives? you would need to include the full
filespec if it is not where the webserver thinks it is or add the path to the
httpd.conf (apache - you'll have to figure it out for yourself on IIS). To find
out where the webserver thinks it should be looking, use something like this:
$out = exec("pwd");
echo $out ."<br>\n";
or
$output = `pwd`;
echo $output ."<br>\n";
Now, does progs live in this directory? if not, how do you expect the server to
find it??? please for help
--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Michael Austin wrote: Piotr Wolski wrote:
i'm trying to do so: exec("progs"); or passthru("progs"); even when i add all the path it doesn't take any result. i tried exec("./progs 2> error_file"); when compiled programm is in the directory where the script is, then the error_file looks like: ./progs: syntax error at line 1: '(' unexpected what the hell does it mean?? ./progs exectuted from command line does what he should do very good..
does the webserver know where .progs lives? you would need to include the full filespec if it is not where the webserver thinks it is or add the path to the httpd.conf (apache - you'll have to figure it out for yourself on IIS). To find out where the webserver thinks it should be looking, use something like this:
$out = exec("pwd"); echo $out ."<br>\n"; or $output = `pwd`; echo $output ."<br>\n";
Now, does progs live in this directory? if not, how do you expect the server to find it???
The programm lives exactly in the directory that your short script shows
on.
Piotr Wolski wrote: Michael Austin wrote:
Piotr Wolski wrote:
i'm trying to do so: exec("progs"); or passthru("progs"); even when i add all the path it doesn't take any result. i tried exec("./progs 2> error_file"); when compiled programm is in the directory where the script is, then the error_file looks like: ./progs: syntax error at line 1: '(' unexpected what the hell does it mean?? ./progs exectuted from command line does what he should do very good.. does the webserver know where .progs lives? you would need to include the full filespec if it is not where the webserver thinks it is or add the path to the httpd.conf (apache - you'll have to figure it out for yourself on IIS). To find out where the webserver thinks it should be looking, use something like this:
$out = exec("pwd"); echo $out ."<br>\n"; or $output = `pwd`; echo $output ."<br>\n";
Now, does progs live in this directory? if not, how do you expect the server to find it???
The programm lives exactly in the directory that your short script shows on.
why it returns so strange error?:
../progs: syntax error at line 1: '(' unexpected
?????progs is compiled program..who can explain that?
Piotr Wolski wrote: Piotr Wolski wrote:
Michael Austin wrote:
Piotr Wolski wrote:
i'm trying to do so: exec("progs"); or passthru("progs"); even when i add all the path it doesn't take any result. i tried exec("./progs 2> error_file"); when compiled programm is in the directory where the script is, then the error_file looks like: ./progs: syntax error at line 1: '(' unexpected what the hell does it mean?? ./progs exectuted from command line does what he should do very good..
does the webserver know where .progs lives? you would need to include the full filespec if it is not where the webserver thinks it is or add the path to the httpd.conf (apache - you'll have to figure it out for yourself on IIS). To find out where the webserver thinks it should be looking, use something like this:
$out = exec("pwd"); echo $out ."<br>\n"; or $output = `pwd`; echo $output ."<br>\n";
Now, does progs live in this directory? if not, how do you expect the server to find it???
The programm lives exactly in the directory that your short script shows on.
why it returns so strange error?:
./progs: syntax error at line 1: '(' unexpected
?????progs is compiled program..who can explain that?
Here is a "wierd" example from the docs:
<?php
exec('/bin/sh -c "/bin/tar -xzf /tmp/'.$filename.' install/desc-file
install/info-file install/deps-file"');
?>
so yours would look like:
exec('/bin/sh -c "/full/file/dir/progs 2 >error_log"');
have you tried using back-tick "`" method?
is the webserver owner also the owner or in the same group as the progs file?
what is line 1 of the progs program?
--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Michael Austin wrote: Piotr Wolski wrote:
Piotr Wolski wrote:
Michael Austin wrote:
Piotr Wolski wrote:
> i'm trying to do so: > exec("progs"); > or passthru("progs"); > even when i add all the path it doesn't take any result. > i tried exec("./progs 2> error_file"); > when compiled programm is in the directory where the script is, > then the error_file looks like: > ./progs: syntax error at line 1: '(' unexpected > what the hell does it mean?? > ./progs exectuted from command line does what he should do very good..
does the webserver know where .progs lives? you would need to include the full filespec if it is not where the webserver thinks it is or add the path to the httpd.conf (apache - you'll have to figure it out for yourself on IIS). To find out where the webserver thinks it should be looking, use something like this:
$out = exec("pwd"); echo $out ."<br>\n"; or $output = `pwd`; echo $output ."<br>\n";
Now, does progs live in this directory? if not, how do you expect the server to find it???
The programm lives exactly in the directory that your short script shows on.
why it returns so strange error?:
./progs: syntax error at line 1: '(' unexpected
?????progs is compiled program..who can explain that?
Here is a "wierd" example from the docs:
<?php exec('/bin/sh -c "/bin/tar -xzf /tmp/'.$filename.' install/desc-file install/info-file install/deps-file"'); ?>
so yours would look like:
exec('/bin/sh -c "/full/file/dir/progs 2 >error_log"');
I tried this and in error_log file is the same as before that there's
syntax error at line 1: '(' unexpected.. have you tried using back-tick "`" method?
no i haven't..
could you let me know what the code should look like?
is the webserver owner also the owner or in the same group as the progs file?
http://www.cs.purdue.edu/help/www/using-cgi.html <--here is everything
about configuration of the server i'm using.. what is line 1 of the progs program?
i don't know cause it's already compiled program..
Piotr Wolski wrote: Michael Austin wrote:
Piotr Wolski wrote:
Piotr Wolski wrote:
Michael Austin wrote:
> Piotr Wolski wrote: > >> i'm trying to do so: >> exec("progs"); >> or passthru("progs"); >> even when i add all the path it doesn't take any result. >> i tried exec("./progs 2> error_file"); >> when compiled programm is in the directory where the script is, >> then the error_file looks like: >> ./progs: syntax error at line 1: '(' unexpected >> what the hell does it mean?? >> ./progs exectuted from command line does what he should do very >> good.. > > > > > > > does the webserver know where .progs lives? you would need to > include the full filespec if it is not where the webserver thinks > it is or add the path to the httpd.conf (apache - you'll have to > figure it out for yourself on IIS). To find out where the webserver > thinks it should be looking, use something like this: > > $out = exec("pwd"); > echo $out ."<br>\n"; > or > $output = `pwd`; > echo $output ."<br>\n"; > > Now, does progs live in this directory? if not, how do you expect > the server to find it??? >
The programm lives exactly in the directory that your short script shows on.
why it returns so strange error?:
./progs: syntax error at line 1: '(' unexpected
?????progs is compiled program..who can explain that? Here is a "wierd" example from the docs:
<?php exec('/bin/sh -c "/bin/tar -xzf /tmp/'.$filename.' install/desc-file install/info-file install/deps-file"'); ?>
so yours would look like:
exec('/bin/sh -c "/full/file/dir/progs 2 >error_log"');
I tried this and in error_log file is the same as before that there's syntax error at line 1: '(' unexpected..
have you tried using back-tick "`" method?
no i haven't.. could you let me know what the code should look like?
is the webserver owner also the owner or in the same group as the progs file?
http://www.cs.purdue.edu/help/www/using-cgi.html <--here is everything about configuration of the server i'm using..
what is line 1 of the progs program?
i don't know cause it's already compiled program..
Well if this error is in the error_file then the output is from the program
itself, not the web server. You will need to find out who wrote the code and
broke it.
can you execute the "c" program from a command prompt (log into the box and
execute it?) if not, there is not much else we can do for you here...
--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Michael Austin wrote: Piotr Wolski wrote:
Michael Austin wrote:
Piotr Wolski wrote:
Piotr Wolski wrote:
> Michael Austin wrote: > >> Piotr Wolski wrote: >> >>> i'm trying to do so: >>> exec("progs"); >>> or passthru("progs"); >>> even when i add all the path it doesn't take any result. >>> i tried exec("./progs 2> error_file"); >>> when compiled programm is in the directory where the script is, >>> then the error_file looks like: >>> ./progs: syntax error at line 1: '(' unexpected >>> what the hell does it mean?? >>> ./progs exectuted from command line does what he should do very >>> good.. >> >> >> >> >> >> >> >> does the webserver know where .progs lives? you would need to >> include the full filespec if it is not where the webserver thinks >> it is or add the path to the httpd.conf (apache - you'll have to >> figure it out for yourself on IIS). To find out where the >> webserver thinks it should be looking, use something like this: >> >> $out = exec("pwd"); >> echo $out ."<br>\n"; >> or >> $output = `pwd`; >> echo $output ."<br>\n"; >> >> Now, does progs live in this directory? if not, how do you expect >> the server to find it??? >> > > The programm lives exactly in the directory that your short script > shows on.
why it returns so strange error?:
./progs: syntax error at line 1: '(' unexpected
?????progs is compiled program..who can explain that?
Here is a "wierd" example from the docs:
<?php exec('/bin/sh -c "/bin/tar -xzf /tmp/'.$filename.' install/desc-file install/info-file install/deps-file"'); ?>
so yours would look like:
exec('/bin/sh -c "/full/file/dir/progs 2 >error_log"'); I tried this and in error_log file is the same as before that there's syntax error at line 1: '(' unexpected..
have you tried using back-tick "`" method?
no i haven't.. could you let me know what the code should look like?
is the webserver owner also the owner or in the same group as the progs file? http://www.cs.purdue.edu/help/www/using-cgi.html <--here is everything about configuration of the server i'm using..
what is line 1 of the progs program?
i don't know cause it's already compiled program..
Well if this error is in the error_file then the output is from the program itself, not the web server. You will need to find out who wrote the code and broke it.
can you execute the "c" program from a command prompt (log into the box and execute it?) if not, there is not much else we can do for you here...
Yes sure, i can execute this program from command line,i can even
write this programm here cause it's very simple program written just for
tests:
#include <stdlib.h>
int main()
{
printf("test");
return 0;
}
And that's all program..
So what can you say about that? this problem is really strange..i hope
you'll find some clue for that cause i'm working under it 24h/day and
still nothing..
thanks, peter
On Mon, 12 Jul 2004 14:22:28 -0500, Piotr Wolski
<wo****@cs.purdue.edu> wrote: Andy Hassall wrote: On Mon, 12 Jul 2004 13:49:21 -0500, Piotr Wolski <wo****@cs.purdue.edu> wrote:
can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why.
Neither do I. Post some details. 'ls' and 'who' are both C programs, not that it actually matters what they're originally written in.
Odds are it's a permissions problem of some sort.
i changed permissions to my compiled C programms: +rwx and nothing changed:(
it certainly sounds like a permission problem ...
does the webserver have permission to use the directory in which the
binary executable lives? (even though the file itself might have
correct permission, if the webserver user can't access the directory,
it won't be able to run the file).
Herbie Cumberland wrote: On Mon, 12 Jul 2004 14:22:28 -0500, Piotr Wolski <wo****@cs.purdue.edu> wrote:
Andy Hassall wrote:
On Mon, 12 Jul 2004 13:49:21 -0500, Piotr Wolski <wo****@cs.purdue.edu> wrote: can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why.
Neither do I. Post some details. 'ls' and 'who' are both C programs, not that it actually matters what they're originally written in.
Odds are it's a permissions problem of some sort.
i changed permissions to my compiled C programms: +rwx and nothing changed:(
it certainly sounds like a permission problem ...
does the webserver have permission to use the directory in which the binary executable lives? (even though the file itself might have correct permission, if the webserver user can't access the directory, it won't be able to run the file).
the programm is example in directory 'example' so the path is
'example/program', example and the programm have the same full permissions..
Piotr Wolski wrote: Michael Austin wrote:
Piotr Wolski wrote:
Michael Austin wrote:
Piotr Wolski wrote:
> Piotr Wolski wrote: > >> Michael Austin wrote: >> >>> Piotr Wolski wrote: >>> >>>> i'm trying to do so: >>>> exec("progs"); >>>> or passthru("progs"); >>>> even when i add all the path it doesn't take any result. >>>> i tried exec("./progs 2> error_file"); >>>> when compiled programm is in the directory where the script is, >>>> then the error_file looks like: >>>> ./progs: syntax error at line 1: '(' unexpected >>>> what the hell does it mean?? >>>> ./progs exectuted from command line does what he should do very >>>> good.. >>> >>> >>> >>> >>> >>> >>> >>> >>> does the webserver know where .progs lives? you would need to >>> include the full filespec if it is not where the webserver thinks >>> it is or add the path to the httpd.conf (apache - you'll have to >>> figure it out for yourself on IIS). To find out where the >>> webserver thinks it should be looking, use something like this: >>> >>> $out = exec("pwd"); >>> echo $out ."<br>\n"; >>> or >>> $output = `pwd`; >>> echo $output ."<br>\n"; >>> >>> Now, does progs live in this directory? if not, how do you expect >>> the server to find it??? >>> >> >> The programm lives exactly in the directory that your short script >> shows on. > > > > > > > why it returns so strange error?: > > > ./progs: syntax error at line 1: '(' unexpected > > ?????progs is compiled program..who can explain that?
Here is a "wierd" example from the docs:
<?php exec('/bin/sh -c "/bin/tar -xzf /tmp/'.$filename.' install/desc-file install/info-file install/deps-file"'); ?>
so yours would look like:
exec('/bin/sh -c "/full/file/dir/progs 2 >error_log"');
I tried this and in error_log file is the same as before that there's syntax error at line 1: '(' unexpected..
have you tried using back-tick "`" method? no i haven't.. could you let me know what the code should look like?
is the webserver owner also the owner or in the same group as the progs file? http://www.cs.purdue.edu/help/www/using-cgi.html <--here is everything about configuration of the server i'm using..
what is line 1 of the progs program?
i don't know cause it's already compiled program.. Well if this error is in the error_file then the output is from the program itself, not the web server. You will need to find out who wrote the code and broke it.
can you execute the "c" program from a command prompt (log into the box and execute it?) if not, there is not much else we can do for you here...
Yes sure, i can execute this program from command line,i can even write this programm here cause it's very simple program written just for tests:
#include <stdlib.h>
int main() { printf("test"); return 0; }
And that's all program.. So what can you say about that? this problem is really strange..i hope you'll find some clue for that cause i'm working under it 24h/day and still nothing.. thanks, peter
I don't do this often, but, if you would like, send me a private email with:
ls -la progs and the directories down to progs, uid/gid of the webserver owner,
should have at least group:read access for the webserver owner.
example:
d?????? uid/gid abc
d?????? uid/gid xxxx
d?????? uid/gid yyy
-rwe?????? uid/gid progs
if you do this, you will probably find your problem also try setting the file
to permissions 777 and all of the directories (temporarily as a test) to see if
there is any difference.
--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Michael Austin wrote:
<snippage> I don't do this often, but, if you would like, send me a private email with:
ls -la progs and the directories down to progs, uid/gid of the webserver owner, should have at least group:read access for the webserver owner.
example:
d?????? uid/gid abc d?????? uid/gid xxxx d?????? uid/gid yyy -rwe?????? uid/gid progs
if you do this, you will probably find your problem also try setting the file to permissions 777 and all of the directories (temporarily as a test) to see if there is any difference.
try something like:
exec('./progs',$a1,$a2);
print_r($a1);
echo "A2 = $a2\n";
helps if we read the docs:
exec ( string command [, array output [, int return_var]])
exec() executes the given command, however it ***does not output anything***. It
simply returns the last line from the result of the command. If you need to
execute a command and have all the data from the command passed directly back
without any interference, use the passthru() function.
then parse through the output array to get the results.
if you want this in the php script then using
$out = `./test`; \\ back-ticks (key next to the !/1 key "~/`")
echo $out;
or the system() command
echo system('./test');
--
Michael Austin.
Consultant - Available.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Piotr Wolski wrote: can anyone help me:
using exec() function in PHP i can execute linux programms like ls,who and other, however i can not execute C programms and i really don't know why.
Please help me, Peter
i've solved my problem:
webserver is on SPARC machine;) and I compiled ewerything on the intel
x86 machine. thats why my C programms didin't want to execute.When i
compiled them one more time on SPARC everything is ok.
thanks everyone for teying to solve my problem. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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--
|
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...
|
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"...
|
by: TPJ |
last post by:
I have the following code:
-----------------------------------
def f():
def g():
a = 'a' # marked line 1
exec 'a = "b"' in globals(), locals()
print "g: a =", a
|
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...
|
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:
|
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)
|
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....
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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...
|
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...
|
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: 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...
| |