0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.