Jump to content

[SOLVED] A little help


CG_dude

Recommended Posts

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 ?

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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");

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.