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

cannot get exec() or passthru() to work?

I cannnot seem to get exec() or passthru() to execute a perl script;
here's the code snippet:

if ($debug) {
echo "username1 = ".$username1."<br>";
echo "dbname = ".$dbname."<br>";
echo "SESSION[dbname] = ".$_SESSION['dbname']."<br>";
echo "Output file = ".$outputfile."<br>";
echo "Project name = ".$projectname."<br>";
echo "Study name = ".$studyname."<br>";
echo "The command to be run is: ".$cmd."<br>";
}

// Run the command!
exec($cmd,$myoutput,$rtnvar);
echo "rtnvar = ".$rtnvar."<br>";

foreach ($myoutput as $line) {
echo $line."<br>";
}

Which produces the results:

username1 = rick
dbname = cgb_lab_data
SESSION[dbname] = cgb_lab_data
Output file = myoutput
Project name = IBS11_1103
Study name = IBS 11
The command to be run is: perl
/home/caseyr/projects/LIMSScripts/3100DataIO/mk3100plt.pl -n 'IBS 11'
-b 1103 -o myoutput -p IBS11_1103 -i S
rtnvar = 13
The command looks perfectly legit, and will run at the command line if
I cut and paste it.

I do not understand the return value of 13.

I can get a simple perl script that takes no arguments to run ok; so I
think this has something to do with the arguments. I've used
escapeshellarg() to no avail. I've always tried the same with system()
and the backtick operator -- nada!

If anyone can spot what I might be doing wrong, I'd appreciate it!

Rick

Nov 1 '05 #1
2 1730
rickcasey wrote:
I cannnot seem to get exec() or passthru() to execute a perl script;
here's the code snippet:

if ($debug) {
echo "username1 = ".$username1."<br>";
echo "dbname = ".$dbname."<br>";
echo "SESSION[dbname] = ".$_SESSION['dbname']."<br>";
echo "Output file = ".$outputfile."<br>";
echo "Project name = ".$projectname."<br>";
echo "Study name = ".$studyname."<br>";
echo "The command to be run is: ".$cmd."<br>";
}

// Run the command!
exec($cmd,$myoutput,$rtnvar);
echo "rtnvar = ".$rtnvar."<br>";

foreach ($myoutput as $line) {
echo $line."<br>";
}

Which produces the results:

username1 = rick
dbname = cgb_lab_data
SESSION[dbname] = cgb_lab_data
Output file = myoutput
Project name = IBS11_1103
Study name = IBS 11
The command to be run is: perl
/home/caseyr/projects/LIMSScripts/3100DataIO/mk3100plt.pl -n 'IBS 11'
-b 1103 -o myoutput -p IBS11_1103 -i S
rtnvar = 13

The command looks perfectly legit, and will run at the command line if
I cut and paste it.

I do not understand the return value of 13.

I can get a simple perl script that takes no arguments to run ok; so I
think this has something to do with the arguments. I've used
escapeshellarg() to no avail. I've always tried the same with system()
and the backtick operator -- nada!

If anyone can spot what I might be doing wrong, I'd appreciate it!


First I'd try changing the single quote to double quotes: "IBS 11"

....as well as providing the full system path to the perl executable.
(run "which perl" to find it on the system).

You may also want to check that there aren't any extra control
characters like tab or newline in the command variable just in case...

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Nov 1 '05 #2
rickcasey wrote:
rtnvar = 13


Hi Rick,

I see that the return value is 13. On Linux error 13 means:

13 (EACCES) - Permission denied

So the webserver user probably doesn't have the permission to execute perl.

HTH.
Peter.
--
http://www.phpforums.nl
Nov 1 '05 #3

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...
17
by: Piotr Wolski | last post by:
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
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...
2
by: Greg Chapman | last post by:
I am at my wit's end trying to get information out of Streamline.net's support dept about my problem. They reply quickly enough, but seem to try and give out the least possible amount of info each...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
3
by: harisinfo | last post by:
Hi everyone, I have a very strange problem when trying to run a simple php script: ob_start(); $e=chdir("/usr/lib") or die("Could not change directory"); echo getcwd(); ob_end_flush(); ...
4
by: Tom | last post by:
I have a script which allows a user to upload a file. The script does some filename editing, mimetype checking, etc., and it's then supposed to send the file to a remote server, without any...
1
by: rickcasey | last post by:
I wonder if anyone has experienced something like this, as it seems truly bizarre and is causing me to tear out my hair (what little there is left of it).... The exec() function just suddenly...
3
by: dinek | last post by:
I am trying to call a Matlab file from PHP. I beleive that using exec() I can call the matlab file. But this does not work I tried exec('matlab -r sample'); I also tried the same with the...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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...
0
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,...

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.