-2

i try to run a command in server from php so i added this code in a php file

 shell_exec($cmd);  

 echo $cmd = "at ".$_POST['time1']." <<< '/usr/local/bin/youtube-dl  ".$_POST['url']." -o ".$out." && /root/bin/ffmpeg -y -i ".$out." -c:v libx264 -s 640x360 -b:v 300k -strict experimental -movflags +faststart -c:a aac FILMA/".$out."___www.example.com___.mp4 && rm -f ".$out."'";

When i run it i get this error

PHP Notice: Undefined variable: cmd in /var/www/html/1.php on line __, referer: http://example.com/1.php

chris85
  • 23,846
  • 7
  • 34
  • 51
Gloytos htyqo
  • 345
  • 1
  • 3
  • 12
  • its not duplicate, this is different problem – Gloytos htyqo Mar 22 '16 at 21:34
  • 1
    Just a shot in the dark, but I believe the cmd variable is undefined... @Gloytoshtyqo No, it is the exact same problem. You are obviously not making any effort to read and understand anything. – Sverri M. Olsen Mar 22 '16 at 21:34
  • 1
    It is the same problem. `$cmd` is not defined. Here `shell_exec($cmd);` The `$cmd` is not previously defined. If that is not the case you went to minimal, and the error message should be different. – chris85 Mar 22 '16 at 21:36

2 Answers2

0

The problem is you are attempting to use $cmd before you have defined it. You use it on line 1 and define it on line 3.

Chris
  • 5,571
  • 2
  • 20
  • 32
0

You must run:

shell_exec($cmd);

after defining $cmd.

Example:

$cmd = "at ".$_POST['time1']." <<< '/usr/local/bin/youtube-dl  ".$_POST['url']." -o ".$out." && /root/bin/ffmpeg -y -i ".$out." -c:v libx264 -s 640x360 -b:v 300k -strict experimental -movflags +faststart -c:a aac FILMA/".$out."___www.example.com___.mp4 && rm -f ".$out."'";

shell_exec($cmd); 
Carl Owens
  • 1,292
  • 8
  • 14