LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-02-2010, 03:43 PM   #1
jfeniello
LQ Newbie
 
Registered: Mar 2010
Posts: 2

Rep: Reputation: 0
shell script acting different via shell/php and http


Hi,
I have a bash script i wrote to do a few things (copy some files, sed some text files, and execute a few apps (ffmpeg, cinelerra).
I also have a php page that runs this bash script through exec();

If i run via the shell (su'd as apache) as: php myphppage.php it executes correctly, copying the files, sed replacements, executes ffmpeg and cinelerra as expected.
When i hit myphppage.php via a browser, it executes, kicks off the .sh script, does the copies, runs ffmpeg, but when it runs cinelerra, it goes nuts, basically resulting in not running correctly, and creating a bunch (10ish) files in the working directory with names like ?, ?a`, p!2, etc.

What i don't understand is what is different from being on ssh as user apache and running php mypage.php vs hitting mypage.php with a browser (since apache runs as user apache).

I'll be happy to provide whatever additional information or files that may be helpful in solving this.

Thanks
-jim
 
Old 03-02-2010, 06:06 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Isn't cinelerra an X graphics application?
If so...
When run from an HTTP server, there will be no X server with which to attach, unless you specify one either by setting $DISPLAY or giving the application a -display commandline argument. This would also require the X server to be configured to accept connections from cinelerra with the accordant host/user permissions. Alternatively, you could run it using a virtual X server, such as Xvfb.
Typically, the environment variables passed along by an HTTP server are quite different from those that spring to life when you log in using a shell. You might look at what the requirements might be, there, too.


---- rod.
 
Old 03-03-2010, 08:21 AM   #3
jfeniello
LQ Newbie
 
Registered: Mar 2010
Posts: 2

Original Poster
Rep: Reputation: 0
It's an X app, but i'm just trying to kick off the batch rendering mode (cinelerra -r myfile.rc). As mentioned it works from the shell logged in as apache, and running via php, just not when http tries to execute the php/script.

So it has something to do with the difference, the environment, etc, just not sure where to start even looking.

-jim
 
Old 03-03-2010, 09:54 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by jfeniello View Post
So it has something to do with the difference, the environment, etc, just not sure where to start even looking.
Can you check the environment variables by modifying the script to run the env command with output directed to a file and then run it in both situations and look for significant differences?

This would do it:
Code:
/usr/bin/env > "${0##*/}.env.out.$$"
 
Old 03-03-2010, 10:24 AM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
What i don't understand is what is different from being on ssh as user apache and running php mypage.php vs hitting mypage.php with a browser (since apache runs as user apache).
The big difference is that a login invokes a number of scripts in the shell, which set up all sorts of things for interactive work. Especially, environment variables, like $PATH, maybe $LD_LIBRARY_PATH, etc. The problem may be as simple as setting $PATH appropriately, or when your script tries to launch the various applications, it should spell out a full, specific filespec to launch.
--- rod.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php/shell script to install mysql,apache and php automatically stranger_6_7 Linux - General 2 08-11-2009 02:07 AM
PHP Shell Script (with MySql) Tony Empire Programming 1 09-20-2005 09:59 AM
Call a shell script from php? jharper101 Programming 2 02-15-2005 12:51 AM
PHP -- How to execute a shell script from PHP using FTP functions?? zoonalex Programming 3 07-29-2004 11:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:58 PM.

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