NYCPHP Meetup

NYPHP.org

[nycphp-talk] Running backtick commands and responding to stdout/in

csnyder chsnyder at gmail.com
Tue Oct 10 12:29:20 EDT 2006


On 10/9/06, Ben Sgro (sk) <skyline at publicmine.com> 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?
>
> Or must I install the ssh2 module and call ssh2_connect( )?
>
> Thanks!
>
> - Ben

Depending on the situation, you could use SSH with key-based
authentication instead of passwords, which would avoid the issue. But
then you have to make sure your script (and the account that runs it)
are both secure.

-- 
Chris Snyder
http://chxo.com/



More information about the talk mailing list