Python's os.execvp equivalent for PHP

command-line-interface, php, python, shell

Solution

If you want shell commands to be interactive, use:

system("mysql -uroot -p db_name > `tty`");

That will work for most cases, but will break if you aren't in a terminal.

Problem

I've got a PHP command line program running. And I want to connect to a mysql shell straight from PHP. I've done this before in Python using os.execvp But I can't get the same thing to work in PHP. I've tried the following functions: - system - passthru - exec - shell_exec example: ``` system('mysql -u root -pxxxx db_name'); ``` But they all seem to wait for mysql to exit and return something. What I really want is for PHP to launch the mysql shell and then exit it self. any ideas?

Original source