mangasource mangasource - 1 year ago 82
Bash Question

PHP Exec - How to only display the result of the last command

I'm using

php function to run a script that grabs a YouTube video in mp3 format (with

At the end of this script I made an
, this is the result I want.

But when I launch my php page, the output is composed of everything
did. Like that:

[youtube] zTkS9SvhHUI: Downloading webpage
[youtube] zTkS9SvhHUI: Downloading video info webpage
[youtube] zTkS9SvhHUI: Extracting video information
[youtube] zTkS9SvhHUI: Downloading js player en_US-vflgFv_Kx
[youtube] zTkS9SvhHUI: Downloading js player en_US-vflgFv_Kx
[download] Destination: /var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).webm
[download] 0.0% of 3.84MiB at 10.17KiB/s ETA 06:26
[download] 0.1% of 3.84MiB at 30.44KiB/s ETA 02:09
[. . .]
[download] 100.0% of 3.84MiB at 4.01MiB/s ETA 00:00
[download] 100% of 3.84MiB in 00:00
[ffmpeg] Destination: /var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).mp3
Deleting original file /var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).webm (pass -k to keep)
/var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).mp3

The only thing I need is :

/var/www/xxx/mp3dl/Kaskade - Whatever Ft KOLAJ (NEUS Remix).mp3

How can I do that? Is there something I did not understand?

EDIT : There is my php code :

$url = htmlspecialchars($_POST['url']);
$choice1 = $_POST['choice1'];
$output = exec('sh scripts/ "'.$url.'"');
if(empty($url)) {
print("<div class='card-panel yellow'>Please add a URL</div>") ;
} else {
if($choice1 == "download") {
print $output;
} elseif($choice1 == "store") {
print "Soon";


Answer Source

Add -q OR --quiet to your command via exec() and it will not output any of the "debug" messages.

From the documentation

-q, --quiet Activate quiet mode

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download