By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,718 Members | 1,438 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,718 IT Pros & Developers. It's quick & easy.

echo for large string?

P: n/a
When I run these two lines from my SSH term $out is printed fine to
STDOUT. When I run it from a web browser nothing is printed out? I have
many php cgi scripts, so I am stumbled as to why this one is not
working?

The only thing I can think of is $out is a large string, around 50kb?

$out = shell_exec ( $executable);
echo $out;

Thanks

Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
el*************@yahoo.com wrote:
When I run these two lines from my SSH term $out is printed fine to
STDOUT. When I run it from a web browser nothing is printed out? I have
many php cgi scripts, so I am stumbled as to why this one is not
working?

The only thing I can think of is $out is a large string, around 50kb?
50Kb is nothing. Couldn't find it in the manual, but I am pretty sure
the sky is your limit.
$out = shell_exec ( $executable);
echo $out;


Are you supressing errormessages?

Check that the web-server account has execute rights.
If you are running selinux, try turn it off (or setenforce permissive),
and check the logs while testing.
/Bent
Jul 17 '05 #2

P: n/a
Basically I am trying to execute a perl script from a php script. I got
it to work by chmoding my perl script from 700 to 704 . But now I get
"permission denied errors" whenver my perl script tries to append/write
to a file?

Is this a perl or php configuration problem? The perl script runs fine
when called from any website. How can I change the script so when it is
called from php it has permissions to write to files?

Thanks!

Jul 17 '05 #3

P: n/a
On 8 May 2005 09:34:57 -0700, el*************@yahoo.com wrote:
Basically I am trying to execute a perl script from a php script. I got
it to work by chmoding my perl script from 700 to 704 . But now I get
"permission denied errors" whenver my perl script tries to append/write
to a file?
704? Should be 755. (Better would be 750 and have the process
running the command be in the same group as the owner of the command.
Is this a perl or php configuration problem? The perl script runs fine
when called from any website. How can I change the script so when it is
called from php it has permissions to write to files?
It's not the script, it's the user running the program not having
permission to write to the directory or files.

Example User: Username Group: Groupname
Dir owned by SomeOtherUsername and Group SomeOtherGroupName with
permissions like

700

Put UserName in the SomeOtherGroupName Group and change the perms on
the group to 770. Change the perms on any file Username needs to
write to 660. (You can use 775 and 664 respectivly if you don't mind
others on your server being able to READ the files.

Thanks!


--
gburnore@databasix dot com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
DataBasix | ۳ݳ޳ݳۺݳ޳ݳݳ޳ݳ۳
| ۳ 3 4 1 4 2 ݳ޳ 6 9 0 6 9 ۳
Black Helicopter Repair Svcs Division | Official Proof of Purchase
================================================== =========================
Want one? GET one! http://signup.databasix.com
================================================== =========================
Jul 17 '05 #4

P: n/a
How about this solution below?

$out = file ('http://www/mydomain.com/cgi-bin/my_perl_script.pl');

for ($i=0; $i< count ($out); $i++ ) { echo $out[$i]; }

Seems more portable and simpler, and it would be easy
to pass parameters to my perl scripy by adding ?param=value
to the URL.

Jul 17 '05 #5

P: n/a
(el*************@yahoo.com) decided we needed to hear...
How about this solution below?

$out = file ('http://www/mydomain.com/cgi-bin/my_perl_script.pl');

for ($i=0; $i< count ($out); $i++ ) { echo $out[$i]; }

Seems more portable and simpler, and it would be easy
to pass parameters to my perl scripy by adding ?param=value
to the URL.

The above doesn't do anything except echo the contents of your perl
script back to the browser - it will not be executed - you've coded
pretty much what the readfile function does.
Neither does it solve your permission issue.
--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #6

P: n/a

"Dave" <da**@REMOVEbundook.com> wrote in message
news:39************@fawlty.homelinux.net...
(el*************@yahoo.com) decided we needed to hear...
How about this solution below?

$out = file ('http://www/mydomain.com/cgi-bin/my_perl_script.pl');

for ($i=0; $i< count ($out); $i++ ) { echo $out[$i]; }

Seems more portable and simpler, and it would be easy
to pass parameters to my perl scripy by adding ?param=value
to the URL.

The above doesn't do anything except echo the contents of your perl
script back to the browser - it will not be executed - you've coded
pretty much what the readfile function does.
Neither does it solve your permission issue.


If the server he's requesting the perl file from excutes it first (looks
like a CGI script by the URL), he would get the output from the script in
the $out variable as an array.

I would also posit that instead of a for loop, he should use foreach. e.g.

foreach($line in $out) { echo $line; }

Much easier to read.
Jul 17 '05 #7

P: n/a
Aidan (no***********@linknet.com.au) decided we needed to hear...

"Dave" <da**@REMOVEbundook.com> wrote in message
news:39************@fawlty.homelinux.net...
(el*************@yahoo.com) decided we needed to hear...
How about this solution below?

$out = file ('http://www/mydomain.com/cgi-bin/my_perl_script.pl');

for ($i=0; $i< count ($out); $i++ ) { echo $out[$i]; }

Seems more portable and simpler, and it would be easy
to pass parameters to my perl scripy by adding ?param=value
to the URL.

The above doesn't do anything except echo the contents of your perl
script back to the browser - it will not be executed - you've coded
pretty much what the readfile function does.
Neither does it solve your permission issue.


If the server he's requesting the perl file from excutes it first (looks
like a CGI script by the URL), he would get the output from the script in
the $out variable as an array.

I would also posit that instead of a for loop, he should use foreach. e.g.

foreach($line in $out) { echo $line; }

Much easier to read.

Good point - I blame the fact I didn't realise that on me having a long
day yesterday ;)
Still might as well use readfile though, then theres no need to bother
with a loop at all.

--
Dave <da**@REMOVEbundook.com>
(Remove REMOVE for email address)
Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.