Skip Menu |

This queue is for tickets about the Net-Appliance-Session CPAN distribution.

Report information
The Basics
Id: 35937
Status: resolved
Priority: 0/
Queue: Net-Appliance-Session

People
Owner: OLIVER [...] cpan.org
Requestors: daniel.dehennin [...] baby-gnu.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: [Feature request] logout on ->close()
Date: Fri, 16 May 2008 14:04:28 +0200
To: bug-Net-Appliance-Session [...] rt.cpan.org
From: Daniel Dehennin <daniel.dehennin [...] baby-gnu.org>
Hello, Firstly thanks for this great module :-) Making some test with a Cisco over a serial line, I see that doing a plain $s->cmd('exit') cause troubles. Is it possible to send some command before closing the connection ? Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
Hi Daniel, On Fri May 16 08:04:57 2008, daniel.dehennin@baby-gnu.org wrote: Show quoted text
> Making some test with a Cisco over a serial line, I see that doing a > plain $s->cmd('exit') cause troubles. > > Is it possible to send some command before closing the connection ?
Are you running the 'exit' command from within configure mode? Please could you give me an example of a short/simple script you run which causes troubles? An example will help me to see the problem... regards, oliver.
CC: daniel.dehennin [...] baby-gnu.org
Subject: Re: [rt.cpan.org #35937] [Feature request] logout on ->close()
Date: Sat, 17 May 2008 13:29:37 +0200
To: bug-Net-Appliance-Session [...] rt.cpan.org
From: Daniel Dehennin <daniel.dehennin [...] baby-gnu.org>
Le 5372 Septembre 1993, OLIVER via RT a envoyé: Show quoted text
> Are you running the 'exit' command from within configure mode?
No, Show quoted text
> Please could you give me an example of a short/simple script you run > which causes troubles? An example will help me to see the problem...
#!/usr/bin/perl -w use strict; use warnings; use FileHandle; # Need it or it crash use Exception::Class::TryCatch; # Syntatic Sugar use Net::Appliance::Session; my $c = Net::Appliance::Session->new( 'Transport' => 'Serial', 'Host' => 'cisco871',); #$c->input_log(*STDOUT); try eval { $c->connect('Name' => 'cisco', 'Password' => 'cisco', 'Line' => '/dev/ttyS0'); print $c->cmd('show access-list'); $c->cmd('exit'); } }; my $err; catch $err and do { print "Net::Appliance::Session $err"; print "Net::Telnet" . $err->errmsg ."\n"; print "Lastline" . $err->lastline . "\n\n"; $c->close; }; $c->close; Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
Download (untitled)
application/pgp-signature 188b

Message body not shown because it is not plain text.

Hi Daniel, On Sat May 17 07:29:57 2008, daniel.dehennin@baby-gnu.org wrote: Show quoted text
> > Please could you give me an example of a short/simple script you run > > which causes troubles? An example will help me to see the problem...
That's great, thanks! Show quoted text
> try eval { > $c->connect('Name' => 'cisco', 'Password' => 'cisco', 'Line' => > '/dev/ttyS0'); > print $c->cmd('show access-list'); > $c->cmd('exit'); > }
I think I see the problem here... When $c->cmd() is called, the module expects it to always have a "return" command prompt afterwards. However with 'exit' on the Serial line there is no returned command prompt because the device has disconnected. In this case I think you can just do only the $c->close() and that will disconnect cleanly for you. You do not need to do $c->cmd('exit'). Is this a good solution, or would you like the module to work differently? regards, oliver.
CC: daniel.dehennin [...] baby-gnu.org
Subject: Re: [rt.cpan.org #35937] [Feature request] logout on ->close()
Date: Sat, 17 May 2008 14:00:36 +0200
To: bug-Net-Appliance-Session [...] rt.cpan.org
From: Daniel Dehennin <daniel.dehennin [...] baby-gnu.org>
Le 5372 Septembre 1993, OLIVER via RT a envoyé: Show quoted text
> I think I see the problem here... When $c->cmd() is called, the module > expects it to always have a "return" command prompt afterwards. However > with 'exit' on the Serial line there is no returned command prompt > because the device has disconnected.
Ok, I see. Show quoted text
> In this case I think you can just do only the $c->close() and that will > disconnect cleanly for you. You do not need to do $c->cmd('exit'). > > Is this a good solution, or would you like the module to work differently?
the $c->close() only close the serial line, when I run minicom over the same serial line I saw that the cisco user is connected. The close does not logout the connected user. Maybe the close can take an argument, like: $c->close(logout => 'exit'); To say that the close must run the 'exit' command to logout, so it does not expect a return value. Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
Download (untitled)
application/pgp-signature 188b

Message body not shown because it is not plain text.

Hi Daniel, On Sat May 17 08:00:53 2008, daniel.dehennin@baby-gnu.org wrote: Show quoted text
> the $c->close() only close the serial line, when I run minicom over > the same serial line I saw that the cisco user is connected. > > The close does not logout the connected user. > > Maybe the close can take an argument, like: > > $c->close(logout => 'exit');
I've uploaded a new version of Net::Appliance::Phrasebook (0.1) and Net::Appliance::Session (0.22) to CPAN. This release has a disconnect() method in the Serial Transport which sends an 'exit' command when you disconnect. I'd be grateful if you could try this out for me and let me know if it works (I don't have access to any serial line kit where I am, right now). There should be no need for you to call $c->cmd('exit') as this is now done within $c->close() for you. You may have to wait a day or so for your local CPAN mirror to update. regards, oliver.
CC: daniel.dehennin [...] baby-gnu.org
Subject: Re: [rt.cpan.org #35937] [Feature request] logout on ->close()
Date: Sat, 17 May 2008 22:03:02 +0200
To: bug-Net-Appliance-Session [...] rt.cpan.org
From: Daniel Dehennin <daniel.dehennin [...] baby-gnu.org>
Le 5372 Septembre 1993, OLIVER via RT a envoyé: Hello Oliver. Show quoted text
> I've uploaded a new version of Net::Appliance::Phrasebook (0.1) and > Net::Appliance::Session (0.22) to CPAN. > > This release has a disconnect() method in the Serial Transport which > sends an 'exit' command when you disconnect. I'd be grateful if you > could try this out for me and let me know if it works (I don't have > access to any serial line kit where I am, right now). > > There should be no need for you to call $c->cmd('exit') as this is now > done within $c->close() for you. > > You may have to wait a day or so for your local CPAN mirror to update.
Thanks a lot, I'll test this on monday since I have no access to a cisco device at home, so the mirror update is not a problem ;-). Regards. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
Download (untitled)
application/pgp-signature 188b

Message body not shown because it is not plain text.

CC: daniel.dehennin [...] baby-gnu.org
Subject: Re: [rt.cpan.org #35937] [Feature request] logout on ->close()
Date: Fri, 30 May 2008 12:15:14 +0200
To: bug-Net-Appliance-Session [...] rt.cpan.org
From: Daniel Dehennin <daniel.dehennin [...] baby-gnu.org>
Le 5372 Septembre 1993, OLIVER via RT a envoyé: Show quoted text
> Hi Daniel,
Hello, Show quoted text
> I've uploaded a new version of Net::Appliance::Phrasebook (0.1) and > Net::Appliance::Session (0.22) to CPAN. > > This release has a disconnect() method in the Serial Transport which > sends an 'exit' command when you disconnect. I'd be grateful if you > could try this out for me and let me know if it works (I don't have > access to any serial line kit where I am, right now). > > There should be no need for you to call $c->cmd('exit') as this is now > done within $c->close() for you.
I test it and it works. Thanks a lot. -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1