0

I wish to create a shell "Menu"

Instead of using bash for my script, I wish to use PHP. Is it possible to run an external program using php, that will interact with the user?

For example, let's say I wanted the php script to run /bin/bash (Just an example), but then when exiting bash, got back to the start of the script (i.e. display the menu again)

Thanks

2 Answers 2

1

Yes.

See:

Specifically:

proc_open('/bin/bash', array(STDIN, STDOUT, STDERR), $a = array());
Sign up to request clarification or add additional context in comments.

4 Comments

And all those allow interaction with the user instead of just running in the "background"?
Edited to include an example.
Thanks for that. What is the best way to supress any error messages (i.e. not showing them to the user)? Infact, it would be cool if the errors could be sent to an email address...
For PHP errors set display_errors, for command errors use something else than STDERR in the array to proc_open.
0

PHP can be used to create your so called "menu" program just like any other programming languages (eg Python/Perl etc). And unless its absolutely necessary, maybe you are calling a proprietary application, PHP has its own functions and modules to interact with the OS. For example, if you want to move/copy files, you can use functions such as rename(), copy() etc. Please read the PHP manual for more. Of course, if you really want to call external program from PHP, you can use exec() or shell_exec() among a few. Check the manual.

1 Comment

Thanks for the tip on PHP's built in functions, however I wish to run "xm console x" to get to the console of a Xen DomU. If only PHP had this build in ;) !

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.