[nycphp-talk] Running backtick commands and responding to stdout/in
Dan Cech
dcech at phpwerx.net
Mon Oct 9 22:00:49 EDT 2006
Ben Sgro (sk) wrote:
> Hey all,
>
> I am attempting to run ssh (w/out the ssh2 module) by backticking commands
> from the command line.
>
> $result = `ssh -l $userStr $hostStr`;
>
> This line causes the script to display the enter password and php seems to
> let it go right to stdin/console.
> Is there any way for php to catch this (since I know its comming) and enter
> the password?
You can do this a few different ways, but probably the most
straightforward is to use proc_open (http://php.net/proc_open).
This lets you define file descriptors for stdin, stdout and stderr so
you can do some pretty complex interaction with external programs.
Dan
>
> Or must I install the ssh2 module and call ssh2_connect( )?
>
> Thanks!
>
> - Ben
More information about the talk
mailing list