Jump to content

exec() Issues


cdromes

Recommended Posts

Howdy

 

I'm attempting to use the exec() in a Linux environment involving files in directories, all of which have been 'chmod 777'd.  This is the function call that doesn't work:

 

$result = exec('perl -S /home/fyejm5/PERL/GetSeq.p '.$Path.'/'.$GI.' '.$Upstream.' '.$len.' /home/websites/genework/html/DATA/'.$Sess_ID.'/'.$Sess_ID, $response, $return_code);

 

print_r(array('result was'=>$result, 'response was'=>$response, 'return code'=>$return_code ));

 

Here's the actual output off the command, which works like a champ when I run it from the command line:

 

perl -S /home/me/PERL/GetSeq.p /home/me/GENOME/MOUSE/CHR_17/149313536 34324324 500 /home/websites/genework/html/DATA/07-12-07--12:03:49/07-12-07--12:03:49

 

The result is the creation of two files in the 07-12-07--12:03:49 directory, each named 07-12-07--12:03:49.txt and 07-12-07--12:03:49.out.

 

This is the result from the print_r:

 

result was =>

response was => Array()

return code => 13

 

What does the response mean?  What error does 13 represent?  Is there something syntactically wrong with the exec()?  This.  Is driving me.  Insane.  I've gotten execs to work in the past, so that makes this one a little heavier on the soul-crushing side of things. 

 

Please help.

 

Jason

 

 

Link to comment
Share on other sites

Try putting your command into a variable first, then echo that to see what it actually looks like before execution. eg;

 

<?php

  $cmd = 'perl -S /home/fyejm5/PERL/GetSeq.p '.$Path.'/'.$GI.' '.$Upstream.' '.$len.' /home/websites/genework/html/DATA/'.$Sess_ID.'/'.$Sess_ID';
  die($cmd);
  $result = exec($cmd, $response, $return_code);

?>

 

13 could meen anything. Its not a reserved error code.

 

 

 

Link to comment
Share on other sites

When I run your code, I get this output to the screen:

 

perl -S /home/fyejm5/PERL/GetSeq.p /home/fyejm5/GENOME/MOUSE/CHR_17/149313536 34324324 500 /home/websites/genework/html/DATA/07-12-07--13:20:24/07-12-07--13:20:24

 

...but it didn't actually work.  When I copy this and paste it directly onto the command line and hit enter, it works perfectly.  This screams "PERMISSIONS PROBLEM", but I don't know what other directories or file(s) need to be changed.    Is it necessary to 'chmod 777' every directory in every path in this command?

Link to comment
Share on other sites

Maybe you have safe mod enabled? From the man...

 

Note: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable.
Link to comment
Share on other sites

I was trying to execute stuff from directories that weren't specified in the  OPEN_BASEDIR directive.  Since I'm not the only user on the box, the solution was to create a directory structure on the web server and move all of the information from my personal directories over.  Why is it that some solutions make you feel galactically stupid?

 

Live.  Learn.  Yay.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.