Jump to content

exec() app via shell vs. http difference


jfeniello

Recommended Posts

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

 

Link to comment
Share on other sites

I'm no guru in either linux or apache, but my understanding of bash is that when you run a bash script it creates a sub-shell that inherits environment settings of the current shell.

 

My initial guess would be the environment when the script is run by apache is not the same as that when run from bash.  I would assume things like stdin, stdout, and pipes would work the same, but like I said I'm no guru.

 

As a step by step process to figure out what is happening, I would recreate the shell script as a new file with commands up to the point that it stops working.  In other words, copy the script and remove all the commands that make it go nuts.  Then try invoking those commands from the PHP script (accessed by apache).  I guess what you really want to know is, Can cinelerra be invoked by PHP under Apache without problems just by itself?

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.