Discussion:
[Fab-user] Running Non-UNIX CLI commands through Fabric
Muhammad Nouman Shahzad
2015-07-10 07:19:23 UTC
Permalink
I am using the latest Fabric API to establish SSH connections. In my
case, SSH-ing to the server opens up a CLI (like the ones Routers have). I
need to execute 'enable' command followed by '_shell' command in-order to
finally open up a UNIX shell. The problem here is that I am unable to
automate these specific commands using Fabric. I have tried the
'shell=False' parameter for the run() function.

Here is an image of the commands I am running, followed by the error being
generated:

[image: Inline image 1]

[image: Inline image 2]

I have been trying different stuff but still haven't been able to solve
this problem through Fabric.

The equivalent implementation using a bash script is as follows:

[image: Inline image 3]

Regards,
M. Nouman Shahzad | Software Engineer | Ebryx Pvt. Ltd.
Cell: +92-323-4292169 | Skype ID: m.noumanshahzad
Waldbieser, Carl
2015-07-10 13:37:56 UTC
Permalink
I think the problem is that every time you issue `run()`, it is like a separate `ssh` into the server.
In other words, no local state is maintained between each 'run()` command.

I am not sure what Fabric has to let you get around this (maybe something to prefix all your commands?), but that is why you are having the trouble, I think.

Thanks,
Carl Waldbieser

----- Original Message -----
From: "Muhammad Nouman Shahzad" <***@ebryx.com>
To: fab-***@nongnu.org
Sent: Friday, July 10, 2015 3:19:23 AM
Subject: [Fab-user] Running Non-UNIX CLI commands through Fabric

I am using the latest Fabric API to establish SSH connections. In my case, SSH-ing to the server opens up a CLI (like the ones Routers have). I need to execute 'enable' command followed by '_shell' command in-order to finally open up a UNIX shell. The problem here is that I am unable to automate these specific commands using Fabric. I have tried the 'shell=False' parameter for the run() function.

Here is an image of the commands I am running, followed by the error being generated:





I have been trying different stuff but still haven't been able to solve this problem through Fabric.

The equivalent implementation using a bash script is as follows:



Regards,
M. Nouman Shahzad | Software Engineer | Ebryx Pvt. Ltd.
Cell: +92-323-4292169 | Skype ID: m.noumanshahzad
Jacob McCoy Wade
2015-07-10 16:52:55 UTC
Permalink
What about something like:
run(‘enable; _shell; uptime’, shell=False)
Post by Waldbieser, Carl
I think the problem is that every time you issue `run()`, it is like a separate `ssh` into the server.
In other words, no local state is maintained between each 'run()` command.
I am not sure what Fabric has to let you get around this (maybe something to prefix all your commands?), but that is why you are having the trouble, I think.
Thanks,
Carl Waldbieser
----- Original Message -----
Sent: Friday, July 10, 2015 3:19:23 AM
Subject: [Fab-user] Running Non-UNIX CLI commands through Fabric
I am using the latest Fabric API to establish SSH connections. In my case, SSH-ing to the server opens up a CLI (like the ones Routers have). I need to execute 'enable' command followed by '_shell' command in-order to finally open up a UNIX shell. The problem here is that I am unable to automate these specific commands using Fabric. I have tried the 'shell=False' parameter for the run() function.
I have been trying different stuff but still haven't been able to solve this problem through Fabric.
Regards,
M. Nouman Shahzad | Software Engineer | Ebryx Pvt. Ltd.
Cell: +92-323-4292169 | Skype ID: m.noumanshahzad
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
Loading...