From: <al....@ac...> - 2007-03-15 16:54:12
|
Hello everyone, =20 I need a bit of help with figuring out a problem with my Expect Perl script and was hoping someone on the list might be able to point me in right direction. I use Expect Perl module in my script for executing commands remotely on some of my servers. The script uses Open SSH (4.2p1) on Solaris 2.8 for logging into each remote server. The remote servers run on a proprietary UNIX OS which can send back any of the following single or multi line prompts during the SSH attempt:=20 =20 The authenticity of host 'testserver (10.10.11.12)' can't be established. RSA key fingerprint is 8e:be:a4:4c:55:09:e8:72:f8:2b:e9:60:0c:84:f6:39. Are you sure you want to continue connecting (yes/no)? =20 or=20 =20 User1@testserver's password:=20 =20 or =20 Blank line Blank line Data ONTAP (testserver.domainname.com) login: =20 For checking the prompts I am trying something similar to the following: =20 $Prompt =3D 'Are you sure you want to continue connecting (yes/no)? '; = - This is the last line from the first prompt above. =20 $which =3D $exp->expect ( 20, "$user_id\@$host_ip\'s password: = ",$Prompt, "login: ","[local_host_name%#]" ); =20 I am using $which variable to find out which prompt is matched. This appears to be working for the first two prompts but not for the third one. I enabled logging to a file and noticed the following when opened the log file via vi: =20 ^M ^M Data OnTap (testserver.domainname.com)^M login: =20 I can't tell if there is any other hidden character in the above prompt. I don't know what regular expression to use to match for the above multi line prompt and am not sure why the $Prompt work for the first multi line prompt. Currently the following packages are installed on my Sun box: =20 expect-5.43.0-sol8-sparc-local Expect-1.20 IO-Tty-1.07 perl-5.8.7-sol8-sparc-local =20 Any help is appreciated.=20 =20 =20 =20 =20 This message is for the designated recipient only and may contain = privileged, proprietary, or otherwise private information. If you have = received it in error, please notify the sender immediately and delete = the original. Any other use of the email by you is prohibited. |