| | |
system() or exec() not working properly
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hello.
I have a linux VPS which is running ubuntu 8.04
I want to execute some command to the terminal, for doing that i use system() or exec() function.
The functions are working properly at localhost, but aren't working properly on the VPS.
Let's say, i have a command :-
This command downloads the video's flv
I use following code in my php code
This should work properly. The command is executed in terminal but i do not receive the output as desired.
There are no error messages, just output from terminal which comes before the actual downloading of the video starts.
Any help would be really appreciated.
Thanks.
I have a linux VPS which is running ubuntu 8.04
I want to execute some command to the terminal, for doing that i use system() or exec() function.
The functions are working properly at localhost, but aren't working properly on the VPS.
Let's say, i have a command :-
PHP Syntax (Toggle Plain Text)
youtube-dl http://www.youtube.com/watch?v=ZMhMZ8Ciyxw -o /home/video.flv
This command downloads the video's flv
I use following code in my php code
PHP Syntax (Toggle Plain Text)
system('youtube-dl http://www.youtube.com/watch?v=ZMhMZ8Ciyxw -o /home/video.flv');
This should work properly. The command is executed in terminal but i do not receive the output as desired.
There are no error messages, just output from terminal which comes before the actual downloading of the video starts.
Any help would be really appreciated.
Thanks.
Just to let you know I find it is best to not use the system command line functions. My reason - I find that some servers just aren't compatible with these functions due to security policies and can even crash a server if the right settings are set on the server. So perhaps if you explain what you are trying to make the command do (like copying a movie) and I will try and find an alternative. I know the file_get_contents() and file_put_contents() are good for copying files on other servers.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
Hi cwarn23. Thanks for your reply.
Probably what i'm looking for is to download a youtube video and edit it using mencoder.
So i probably want to use youtube-dl and mencoder, which are installed on my VPS
I face same problem using exec(), sytem() or passthru()
If commands are run manually using ssh, it works fine.
But if done through php, it doesn't work fully and properly.
Where can the problem be ?
Probably what i'm looking for is to download a youtube video and edit it using mencoder.
So i probably want to use youtube-dl and mencoder, which are installed on my VPS
I face same problem using exec(), sytem() or passthru()
If commands are run manually using ssh, it works fine.
But if done through php, it doesn't work fully and properly.
Where can the problem be ?
Last edited by phpboy; Jul 24th, 2009 at 8:35 am.
If you own a VPS (Virtual Private Server) like I do and really want to use those functions then you will need to find the security policies for php and set the security policies to allow php to interact with the core system. I think it's mainly a thing that's not enabled by default due to security reasons but I myself am not sure on how to enable these security policies. I'll google a bit for you to see if I can find such info.
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
I read that making the following the code can sometimes work...
Also I read that there is some setting in the php.ini file for the exec function but I can't seem to find it.
php Syntax (Toggle Plain Text)
exec('youtube-dl http://www.youtube.com/watch?v=ZMhMZ8Ciyxw -o /home/video.flv'); exec('exit(0)');
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
I tried using exit(0) but it doesn't made any change.
One more thing...for example we execute a command as :-
It gives output as :-
and then the browser stops.
The execution stops exactly when the process starts (i.e when it displays the actual download percentage..like speed and percentage of download completion)
While doing same on localhost, it works fine.
Same happens with mencoder...the output displayed is upto when the real conversion of video starts.
I think there need to be some setting to be changed in php.ini
I will be looking in.
One more thing...for example we execute a command as :-
php Syntax (Toggle Plain Text)
echo exec('youtube-dl http://www.youtube.com/watch?v=ZMhMZ8Ciyxw -o /home/video.flv');
It gives output as :-
PHP Syntax (Toggle Plain Text)
Video data found at http://v9.lscache3.googlevideo.com/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cburst%2Cfactor&itag=5&ipbits=0&signature=CAC74228191224D270888F734075E7113F0F07A4.C33E764E27F6D8021E8D79804B38232BFF4DEF3D&sver=3&expire=1248462000&key=yt1&factor=1.25&burst=40&id=7e8e3d7fc6e4e43d
and then the browser stops.
The execution stops exactly when the process starts (i.e when it displays the actual download percentage..like speed and percentage of download completion)
While doing same on localhost, it works fine.
Same happens with mencoder...the output displayed is upto when the real conversion of video starts.
I think there need to be some setting to be changed in php.ini
I will be looking in.
Last edited by phpboy; Jul 24th, 2009 at 9:22 am.
Maybe php doesn't have the permissions to access the base of the home folder where as when you do it through the command terminal you are logged in as administrator. So try something like the following but replace the end address with the address to your web directory.
So the public_html folder is the base of your website.
PHP Syntax (Toggle Plain Text)
echo exec('youtube-dl http://www.youtube.com/watch?v=ZMhMZ8Ciyxw -o /home/user/public_html/video.flv');
Try not to bump 10 year old threads as it can be really annoying.
http://syntax.cwarn23.net/
My favourite PC. - Oopy Doopy Do 2U2!
http://syntax.cwarn23.net/
Smilies: ^_* +_+ v_v -_- *~*` My favourite PC. - Oopy Doopy Do 2U2!
![]() |
Similar Threads
- my socket programming not working properly to send data from client to server (Python)
- System Restore not working (Windows NT / 2000 / XP)
- Why isn't my modified KeyTyped method working properly? (Java)
- In perl script system("cd c:\mnt"); is not working. (Perl)
- Windows firewall not working properly (Windows Software)
- atomic increment is not working properly.. (Assembly)
- System Restore not working.. (Windows Vista and Windows 7)
- CD - DVD ROM Drive not working properly (Storage)
- Intel D815EEA PCI cards are not working properly (Windows NT / 2000 / XP)
Other Threads in the PHP Forum
- Previous Thread: MySQL headache
- Next Thread: PHP Rapid Development
Views: 497 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube






