NYCPHP Meetup

NYPHP.org

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

Ben Sgro (sk) skyline at publicmine.com
Mon Oct 9 22:04:23 EDT 2006


Hello Dan,

Just gave that a quick read. Very cool.
I will post results tomorrow.

Thanks!

- Ben
----- Original Message ----- 
From: "Dan Cech" <dcech at phpwerx.net>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Monday, October 09, 2006 10:00 PM
Subject: Re: [nycphp-talk] Running backtick commands and responding 
tostdout/in


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
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php





More information about the talk mailing list