shell script acting different via shell/php and http
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.