LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-11-2006, 02:20 AM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
php: exec can't run lynx after apache restart


Kind of odd...

I have a php page that lives in a directory with a tcsh script. In the tcsh script, I use lynx to fetch some info from the web, parse it & echo it out. The php takes the echoed out stuff, formats it, and displays it.

This all worked fine and dandy until i restarted apache after changing ports (and, subsequently, changing them back). Now, the return value from the tcsh script does not contain the lynx dump but does contain other text if I add it.

This does work if I run the php page from the command line rather than through a browser, so I'm guessing it's some sort of permissions issue, but both lynx and the tcsh script are read + executable by all.

 
Old 01-11-2006, 06:54 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
Does your php.ini file have safe_mode on?

Quote:
; When safe_mode is on, only executables located in the safe_mode_exec_dir
; will be allowed to be executed via the exec family of functions.
safe_mode_exec_dir =
BTW: if you enable:
Quote:
; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
allow_url_fopen = On
in php.ini, you can open any remote URL like any regular file and use native php functions to get your data. This way you can do away with the shell script, and exec call altogether.
 
Old 01-11-2006, 09:04 PM   #3
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally Posted by bulliver
Does your php.ini file have safe_mode on?
No, safe mode is off. I'll look into the allow url bit.

Thanks.
 
Old 01-16-2006, 04:39 PM   #4
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
from php.ini:

allow_url = on
safe_mode_exe_dir =

but this still doesn't work when run through a browser. I'm completely stumped.. I've tried:

making the shell script echo output that php catches through exec.
making the shell script write to a file, then read the file through php.
using fopen on a URL i.e. fopen("http://some.url.com",'r');

Basically, If run through a browser and the shell script runs lynx, it doesn't work, if the shell script doesn't run lynx, but rather, runs "ls" or something of the sort, it does work. If I run the php from the command line rather than a browser, it works fine. There doesn't seem to be permissions problems and this was working before I restarted apache. Note: when I say "it doesn't work", I mean all the output that should come from lynx is missing, but if I add formatting output like "text should go here: ", that will print, but the text that comes from lynx doesn't.



update: if I check out the error log on the machine running appache, I get a "/root/: No such directory"
my script isn't accessing anything in /root and apache is run under the user "apache" - could this be a path issue?... hmm... if I echo out the path variable from the php through the brwoser, /root is not involved.

Last edited by BrianK; 01-16-2006 at 04:58 PM.
 
Old 01-16-2006, 05:47 PM   #5
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Solved

I can't explain why it worked before and does not now, but upgrading lynx solved the problem.

I managed to find a few threads on other boards regarding this very problem - none with answers so if you come across this issue, upgrading lynx seems to fix it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache 2, PHP 5, SuSE 9.2 - cannot run php files dickohead Linux - Networking 6 06-28-2006 10:25 AM
php exec() function in chrooted apache clau_bolson Linux - Software 2 12-21-2005 08:29 AM
PHP / VideoLAN / Fedora Core Question - how can I get the PHP "exec" function to work gtrawoger Linux - Software 3 12-21-2005 06:51 AM
apache+php not working after restart raduromeo Linux - Software 5 11-23-2005 06:16 AM
Can't run lynx xcoach Linux - Software 1 02-13-2004 12:54 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration