Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically enter input

Status
Not open for further replies.

blarneyme

MIS
Jun 22, 2009
160
0
0
US
I need to automatically enter input without having to type yes or a password. Trying to use Open2 but not getting it to work.

Code:
#!/usr/bin/perl

use IPC::Open2;
$pid = open2(*READFROM, *WRITETO, "/tmp/Install.sh arg1");
print WRITETO "here's your input\n";
while ($output = <READFROM>){
        if($output =~ m/The authenticity of host 'server.mydomain.org (1.2.3.4)' can't be established.
                        RSA key fingerprint is 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00.
                        Are you sure you want to continue connecting \(yes\/no\)\?/){
  
                print WRITETO "yes\n";
        }
}
close(WRITETO);
close(READFROM);

I need it to automatically enter 'yes' and the return to continue without any interaction. I've tried a number of variations.

Thanks.
 
I would suggest either the perl expect module or the tcl based expect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top