Forgotten Player agucova Forgotten Player agucova - 4 years ago 293
PHP Question

Pass STDOUT (Bash) to PHP Variable

I want to pass the stdout of a command in bash (ex.

uptime
) to a PHP variable, let's say
uptime
too.
How this can be done?

Answer Source

Use shell_exec for returning the output of shell commands:

<?php
    $output = shell_exec('uptime');
    echo $output;
?>

Result:

18:17  up 12 days, 13:39, 3 users, load averages: 1.80 1.78 1.75

http://php.net/manual/en/function.shell-exec.php

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