CG_dude Posted January 29, 2009 Share Posted January 29, 2009 All that may help, I appreciate the effort in advance. I have an internal php site, Version 4.2.3. My issue is I'm trying to pull data from a perl script that pulls a sql query from sybase. #1 - When I run the perl script from the command line (perl.pl) it outputs what I need, but when I try to execute it from the php page, nothing shows, #2 - After #1 didn't work, created a shell script that basically runs the perl script and output the file to perl.txt and tried to retrieve the output. Here is the shell script (perl.pl > /path/to/text.txt), when I run the shell script from the command line it works. When I do it from the the PHP page, it doesn't give the output, and I noticed it doesn't output it to the txt file either. On both, I tried exec, system, paathrough, etc.... Any suggestions ? Quote Link to comment Share on other sites More sharing options...
premiso Posted January 29, 2009 Share Posted January 29, 2009 You said you tried the etc, just checking did you try shell_exec? If you have, had you looked into virtual? Give either or both a try and see if that helps. If you have tried them, let us know and I will throw some more ideas at ya. EDIT: I just found this too http://devzone.zend.com/node/view/id/1712 which may help. Quote Link to comment Share on other sites More sharing options...
ober Posted January 29, 2009 Share Posted January 29, 2009 Why are you involving Perl in the first place? Why not go directly to the DB with PHP? Surely you can use an available library to talk to Sybase. Also, if the info isn't going into the text file from the perl script, that seems like a problem with the perl, not the PHP. Do you administer the server? What version of Perl are you running? Is the server setup to allow you to run exec or other system commands? Can you post the PHP code? Quote Link to comment Share on other sites More sharing options...
CG_dude Posted January 29, 2009 Author Share Posted January 29, 2009 I have tried Virtual and Shell_exec Also, to the admin, the shell script works from the command line and appends the info to the txt file, just doesn't work with in PHP Some of the ones I've tried <?php $output = shell_exec('/opt/hpws/apache/htdocs/perl_shell_test.sh'); echo "<pre>$output</pre>"; ?> And <?php virtual ("users/apache/hpws/apache/htdocs/perl.pl"); ?> Quote Link to comment Share on other sites More sharing options...
corbin Posted January 29, 2009 Share Posted January 29, 2009 Does the user under which Apache runs have execute access to the perl binary and read access to the perl_shell_test.sh? Quote Link to comment Share on other sites More sharing options...
ober Posted January 29, 2009 Share Posted January 29, 2009 My guess is that whatever user is setup on the server to run PHP is not necessarily permissioned (is that a word) correctly to run the perl script. That is typically the case when it works from the command line but not from PHP. And if it isn't a user issue, it's a permission issue within PHP. I actually had this same problem at my previous job and I can't for the life of me figure out what I did to solve it. I think I had to modify php.ini to allow it. Quote Link to comment Share on other sites More sharing options...
CG_dude Posted January 29, 2009 Author Share Posted January 29, 2009 Case Solved A co-worker of mine did this <?php echo shell_exec('pa_shell_test.sh'); echo shell_exec('cat pa_box_settle.txt'); ?> It runs the perl script via the shell script and cats the txt file it is appending to. Thanks for all the suggestions Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.