Current location: Hot Scripts Forums » Programming Languages » PHP » PHP 5.0 - problem with executing unix commands


PHP 5.0 - problem with executing unix commands

Reply
  #1 (permalink)  
Old 06-16-08, 12:39 AM
jkpolsar jkpolsar is offline
New Member
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Question PHP 5.0 - problem with executing unix commands

We recently upgraded to PHP 5.2.3 and are now running into some problems with a script we previously wrote. It is a script that uses FFMPEG to convert uploaded MPG or WMV files into FLV. Since files are uploaded by users, it uses cronjobs to check if a new file has been uploaded every minute and then converts. It uses the exec() function to run the FFMPEG commands.

It used to work fine, but after the upgrade does not any more. I have checked the more obvious problems, such as if PHP is in safe mode (it's not). I can still use PHP's exec() function to run simple commands like "ls", but cannot use it for "chmod" or "ffmpeg", which is what I need. I believe it is a permissions problem, and all I have to do is allow Linux user "videogam" (what the PHP script runs as) the correct permissions to execute the "chmod" and "ffmpeg" commands. Since I don't use Unix that much, I don't know if this is a PHP issue or a Linux one, nor how to do this.

I've searched all over the internet for a solution but I have yet to find one. Please let me know if this was confusing.

Thanks for the help.

EDIT: the only error returned using system() is the number "127" with no text description

Last edited by jkpolsar; 06-16-08 at 12:41 AM. Reason: added in error message
Reply With Quote
  #2 (permalink)  
Old 06-16-08, 06:18 AM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
This might be a long shot but you can also execute unix commands by using back ticks...

PHP Code:

$list = `ls -a`; 

$list contains what is returned from that command... maybe it will work, I'm not too sure.
__________________
"BTW, I can't program at all the only thing I figured out is how to upload templates to my server."

Last edited by nova912; 06-16-08 at 06:20 AM.
Reply With Quote
  #3 (permalink)  
Old 06-16-08, 01:04 PM
jkpolsar jkpolsar is offline
New Member
 
Join Date: Dec 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for the suggestion. However, that doesn't seem to be the problem. The problem is that PHP is not able to execute any commands that require a higher access level (like chmod).

Basically, I believe that the actual PHP function is working okay (e.g. exec(), system(), or backticks), but the user that PHP is running as is not allowed to perform higher-level functions. How do I make it so that PHP can execute a few root-level functions (chmod and ffmpeg in my case) without the security concerns of letting it run as root?

Thanks!
Reply With Quote
  #4 (permalink)  
Old 06-16-08, 08:53 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Ideas:

Change the way your script runs to eliminate the chmod requirement.

Adjust the permissions on the FFMPEG code to allow Apache to execute it.

Check the log files to see if there are any helpful error messages (/etc/httpd/logs/error_log)

Send a ticket to the hosting company (if this isn't on your server), with the question

http://httpd.apache.org/docs/2.2/mod...mon.html#group, http://httpd.apache.org/docs/2.2/mod...mmon.html#user

Check http://us2.php.net/manual/en/function.ssh2-exec.php
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and JavaScript problem twome PHP 1 04-19-06 06:43 PM
PHP Windows 2003 Problem - Help Please dwdviper PHP 1 04-19-06 01:39 PM
.htaccess and PHP Redirect problem dodod PHP 3 06-19-05 10:56 PM
PHP email form problem jcwilde1 PHP 2 06-18-05 11:19 PM
MultiThreading in PHP on Unix Damien PHP 1 08-03-03 07:00 PM


All times are GMT -5. The time now is 07:48 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.