From: David B. <dbe...@an...> - 2006-04-21 23:40:38
|
I played around with this some and on my XP PRO system OS Name Microsoft Windows XP Professional Version 5.1.2600 Service Pack 2 Build 2600 With the latest cygwin (cygcheck -s) Cygwin DLL version info: DLL version: 1.5.19 DLL epoch: 19 DLL bad signal mask: 19005 DLL old termios: 5 DLL malloc env: 28 API major: 0 API minor: 150 Shared data: 4 DLL identifier: cygwin1 Mount registry: 2 Cygnus registry name: Cygnus Solutions Cygwin registry name: Cygwin Program options name: Program Options Cygwin mount registry name: mounts v2 Cygdrive flags: cygdrive flags Cygdrive prefix: cygdrive prefix Cygdrive default prefix: Build date: Fri Jan 20 13:28:43 EST 2006 CVS tag: cr-0x5ef Shared id: cygwin1S4 I get the same thing. Using your slightly modified code #!/usr/bin/perl use Expect; $Expect_Handle = new Expect; $Responses = "grimlock ogin: "; $Expect::Debug=1; $Result = $Expect_Handle->spawn('telnet grimlock'); $Pattern_ID = $Expect_Handle->expect($Timeout,'-re', $Responses); I get $ perl test.pl spawn id(3): beginning expect. Timeout: unlimited seconds. Current time: Fri Apr 21 12:27:47 2006 Waiting for new data (unlimited seconds)... spawn id(3): new data. spawn id(3): EOF spawn id(3): exit(0xFF00) spawn id(3): closing... Returning from expect with TIMEOUT or EOF But if I change from telnet to ssh, things seem normal $ perl test.pl spawn id(3): beginning expect. Timeout: unlimited seconds. Current time: Fri Apr 21 12:29:07 2006 Waiting for new data (unlimited seconds)... spawn id(3): new data. spawn id(3): read 52 byte(s). Enter passphrase for key '/home/myuser/.ssh/id_dsa': Waiting for new data (unlimited seconds)... Looks like telnet to me. Can you use ssh? BP Mopuri, Shailaja wrote: > Hi, > Sorry for skipping the details. What I am trying to say is, telnet is not spawned as I don't see it in the Task Manager Processes window. I don't get any errors but telnet is not invoked. I did try using > Net::Telnet but did not make any difference. As for "\n", the shell does strip the whitespace. > > Thanks for responding to my mail. > > Shailaja > > -----Original Message----- > From: Roland Giersig [mailto:RGi...@cp...] > Sent: Friday, April 21, 2006 1:38 AM > To: Mopuri, Shailaja > Cc: exp...@li... > Subject: Re: [Expectperl-discuss] Telnet not working from Cygwin when using Expect/Perl > > Quoting "Mopuri, Shailaja" <sha...@in...>: > >> Hi, >> I am trying to invoke telnet using Expect from Perl in Cygwin. The same >> code works in Linux systems which means there is something different when invoked from Cygwin shell. Can anyone suggest any workarounds or suggestions to fix this issue. > > What are the symptoms of the failure? Any error messages? "This does not work" is not an allowed problem-description for a technician... :-) > > Alternatively you could try to use Net::Telnet to connect and pass its filehandle to exp_init, so you would avoid the cygwin shell and ptys alltogether. > >> Below is the sample code that I am trying to get it work >> >> Thanks, >> Shailaja >> >> #!/usr/bin/perl >> >> # use module >> use XML::Simple; >> use Expect; >> >> #Create the Expect handle >> $Expect_Handle =3D new Expect; >> $Cmds =3D "telnet atsism01 623"; >> $Responses =3D "server:"; >> $Result =3D $Expect_Handle->spawn($Cmds."\n"); > > Why the "\n"? This would make the last argument "623\n" (if the shell wouldn't strip whitespace). > >> # Clears the previous output accumulated incase of match failures $Expect_Handle->clear_accum(); >> $Pattern_ID =3D $Expect_Handle->expect($Timeout,'-re', $Responses); #Capture the current prompt >> $Current_Prompt =3D $Expect_Handle->match(); >> #Capture the output >> $ActualOutput =3D $Expect_Handle->before().$Current_Prompt; >> =09 >> > > -- > RGi...@cp... > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd_______________________________________________ Expectperl-discuss mailing list > Exp...@li... > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss > > > !DSPAM:4448f1cd103472959816485! > |