You may be able to use the underlying paramiko library that Fabric itself
relies on, but I don't have any personal experience with it.

On Fri, Nov 18, 2016 at 3:57 AM <[email protected]> wrote:

> Hello Brandon,
>
>
> (sorry for the direct reply, I didn't notice that the To: wasn't to the ML)
>
> Thank you for your reply.
> Unfortunately sending newlines (or carriage return) between two commands
> inside one run() didn't help.
> Since between each run() I'm loosing my execution session, are you aware
> about another ssh module for Python that doesn't have this behaviour?
>
> Many Thanks,
>
> Regards,
>
>
> Alexandre
>
>
> ----- Original Message -----
> From: "Brandon Whaley" <[email protected]>
> To: "a hocquel" <[email protected]>, [email protected]
> Sent: Thursday, 17 November, 2016 7:54:24 PM
> Subject: Re: [Fab-user] HP switches and run() received nonzero return code
> -1 while executing
>
>
> Fabric was written with accessing *nix based servers in mind, so some
> things it does don't work correctly with non-standard ssh implementations.
> I'm not sure if HP is returning the -1 code or if Fabric is not getting one
> at all and as such returns -1 as an error value. Either way, it sounds like
> you'll always need to use warn_only=True for this device.
>
>
> One of the biggest differences between an interactive ssh session and
> Fabric is that when you use run(), while only one ssh connection is ever
> made, a new command execution session is initiated over that connection for
> each operation. That means things like environment variables are "fresh" at
> every call to run(). I suspect this is why your "screen-length disable"
> command does not take effect, since HP's docs state "Note that this command
> is applicable to the current user only and when a user re-logs in, the
> settings restore to the system default."
>
>
> Have you tried sending newlines between two commands in the same run()?
> That might be a workaround for you if the switch allows it.
>
>
> On Thu, Nov 17, 2016 at 10:43 AM < [email protected] > wrote:
>
>
> Hello,
>
>
> I'm new here, and before writing this email I searched on the archives
> without success, so please excuse me if this question was already asked.
>
> I'm trying to "display current-configuration" through ssh on HP 5820
> series switches with this piece of code :
>
> from fabric.api import *
>
> env.user = 'toto'
> env.hosts = ['192.168.72.10']
> def displaycurr():
> with settings(hide('warnings'), warn_only=True):
> # below command is normally used to prevent the "more"
> run('screen-length disable ', shell=False)
> run('display current-configuration ', shell=False)
>
>
> As written in the email's subject, every ran command returns a nonzero
> code, implying that even if I forced the "keep running" with the
> warn_only=True option, after each run command the ssh session is exited.
> Therefore I lost the first command advantage and then I got the "more"
> during the second.
>
> Same code (without warn_only) and the right Cisco commands does work well
> on Cisco switches.
>
>
> By any chance, is there someone that experienced the same issue (not
> necessarily with HP switches) and managed to keep the ssh session opened
> between both commands?
>
>
> Many Thanks,
>
> Regards,
>
>
> Alexandre
>
>
>
>
> _______________________________________________
> Fab-user mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
> _______________________________________________
> Fab-user mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/fab-user
>
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to