Executing Run/CMD commands with PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ven0m
Forum Newbie
Posts: 3
Joined: Fri Oct 13, 2006 4:16 am

Executing Run/CMD commands with PHP

Post by ven0m »

Hey guys. Here's the thing, i'v decided to experiment a bit, and create a mini version of you tube, just for the sake of it, to understand how it works. Now, the basic idea, is for the script to convert video files into FLV files, and stream them. As far as i understood, the way to do that, is using FFMPEG and a command, which should be ran through CMD - ffmpeg -i file.avi file.flv

The question is - how do i get PHP script to execute it for me?
As far as i understood, it's done with one of several functions - exec or system.
Can anybody help me out please?

UPDATE:
I'v tried running the following script:

Code: Select all

<?php
  $cmd = "ipconfig";
  system($cmd,$return_value);
  ($return_value == 0) or die("returned an error: $cmd");
?>
But for some reason, it just wont run, causing the browser to stop at some point, while loading
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Works for me.
So does this.

Code: Select all

<?php
$cmd = "ipconfig";
$a = exec($cmd, $output, $return_value);
print_r($output);
?>
Post Reply