From: <al....@ac...> - 2007-03-15 20:47:52
|
Hi Brad, =20 Thank you for your input. I installed vim and open my log fle in hex mode. The ^M character is now displayed as <0d>. I see it repeated twice at the end of one of the lines. Also, in the following statement=20 $which =3D $exp->expect ( 20, "$user_id\@$host_ip\'s password: = ",$Prompt, "login: ","[local_host_name%#]" ); initially I had .* characters in the "login: " field (it looked like "login:.*" ) but then I removed them and left the double quotes as they were. I also tried single quotes with and without the extra space after the colon but neither one worked. =20 =20 =20 Al =20 *=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*= =3D*=3D*=3D* Al Pashazadeh Accenture Technology Infrastructure Services Cross Center Operations [ U.S. ] Dallas, Infomart =20 Phone: (469) 665-6553 VPN: 66/56553 MSN: al....@ac... =20 *=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*=3D*= =3D*=3D*=3D* ________________________________ From: btr...@gm... [mailto:btr...@gm...] On Behalf Of Bradford Ritchie Sent: Thursday, March 15, 2007 1:05 PM To: Pashazadeh, Al Cc: exp...@li... Subject: Re: [Expectperl-discuss] Multi Line Prompts - Help =20 I would use a hex editor to view the log file so that you can see all characters literally. Use "man ascii" to figure out what each one means. Sometimes it's a CR or LF character that you're not catching.=20 vim can do hex editing. Start vim, then type :help hex and it will explain how to do it. There are other hex editors out there if you don't want to use vim. It's strange that the third prompt isn't matching since that's the simplest one out of the three. The expect command you show below has "fancy" double-quotes around login: How did this happen since I would expect you to cut/paste the command all at once. =20 The only suggestions I have is to try to do a single expect command for just the third prompt to make sure you can match it. Then add the other two. Also try taking out the space following the colon. It probably won't help, but try anyway. :)=20 -- Brad On 3/15/07, al....@ac... < al....@ac... <mailto:al....@ac...> > wrote: 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 <http://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 <http://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 <http://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.=20 ------------------------------------------------------------------------ - Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your=20 opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDE V _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss=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. |