0

I have a HTML page and that have two buttons, i need to run 2 different "sh" commands when i click on the buttons, using PHP and Ajax how can i achieve this?

2
  • 1
    what did you achieve so far? Commented Feb 21, 2018 at 11:19
  • 1
    by writing code.. Commented Feb 21, 2018 at 11:22

2 Answers 2

1

You can ajax request to php page and use exec

<?php
    // outputs the username that owns the running php/httpd process
    // (on a system with the "whoami" executable in the path)
    echo exec('whoami');
?>
Sign up to request clarification or add additional context in comments.

2 Comments

if he have permission to do that!
Of course, It is the basic to execute Shell command using php 👍🤔
0
<?php
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
?>

Source: http://php.net/manual/de/function.shell-exec.php

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.