in reply to Re: Dialog with UNIX shell
in thread Dialog with UNIX shell

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Dialog with UNIX shell
by ikegami (Patriarch) on Jul 19, 2007 at 21:12 UTC
    I presumed you were communicating with this shell through a pipe. How are you communicating with the shell?
      No, I am writing the programm which installs ssh keys on remote servers. my @servers = ('j5'); foreach my $server (@servers) { my $cmd = "bash"; if (system($cmd)) { print "$cmd failed\n"; next; } my $res = qx(ssh $server); if ($res =~ m/RSA\skey\sfingerprint/) { HERE I NEED TO ANSWER YES/NO AND PRESS ENTER

        You need something like IPC::Open2 instead of qx() since you want 2-way communication with ssh. qx() only allows to receive from the child process.

        That said, you're probably better off using Expect and let it worry about the nitty gritty parent-child communication details.

        If you use (y/n) instead of yes/no, you can do it like this
        my $response = <STDIN>; chomp($response); if (lc($response) eq 'y') { ...etc