Re: run ssh on linux through php???
| From: | Chris Shiflett | Date: | Sun, 15 Sep 2002 23:49:16 +0000 |
| Subject: | Re: run ssh on linux through php??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116477@lists.php.net to get a copy of this message | ||
Well, your problem is that ssh is interactive. You can call ssh passing the password on the command line to get around your immediate problem, but what good does it do for PHP to connect via ssh, only to exit prior to you seeing anything in the Web browser?
Remember that PHP completes execution prior to the response being sent from the Web server to your browser. Thus, PHP is finished by the time you see a Web page. If you want to do anything interactive, it either has to happen on the client side (such as a Java applet), or it has to somehow be able to coexist with the transactional nature of the Web.
What you might want to look into are ways of doing whatever you want to do in a single command. For example, if you just want to execute a command on a remote machine, there are ways to do this aside from an interactive login.
Finally, if what you need to do absolutely must be done interactively, I suggest looking into the Expect scripting language. An Expect script can be executed by PHP, and you will be "waiting for a response..." until it finishes.
Happy hacking.
Chris
michael wrote:
i want to run ssh through php and any browser.i have tried something with the functions: system(),shell_exec(). e.g. shell_exec(sss -l username localhost). the problem is that my browser doesn't return something.So, i can't login because i can't give the password.