Running send_command with variable not working.
See original GitHub issueWhat am I doing wrong below. I am trying to run a show run command from the list intfaces using the variable x. I get no output.
for line in ipfile:
device['ip']=line.strip()
print("Connecting to Device " + line)
net_connect = ConnectHandler(**device)
time.sleep(2)
print ("Checking Interface Configurations")
intfilter = net_connect.send_command("sh run | i Gi.")
striplist = intfilter.rstrip()
intfaces = []
intfaces.append(striplist)
for x in intfaces:
intconfig = net_connect.send_command("sh run " + x)
print(intconfig)
****the indentation doesn’t seem to show up
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
expect command variable with pipes and special characters ...
The command I want to run in the remote server is: ... So, the problem is that I want to execute a multiple...
Read more >sendCommand or postUpdate does not work in OH 2.1 - why?
I just try to upgrade from openhab 1.8 to 2.1. In OH 1.8 I have over 100 rules with sendCommand or postUpdate. In...
Read more >How can I use " inside expect send command with variable
I have used the /usr/bin/expect to SSH into my other system and execute some commands using send. Here is command that need to...
Read more >Working with parameters using Run Command commands
Run parameters by using either Run Command on the Systems Manager console or the AWS CLI. ... aws ssm send-command \ --document-name "AWS-RunShellScript" ......
Read more >docker run - Docker Documentation
docker run: The `docker run` command first `creates` a writeable container ... This will not work, because by default, most potentially dangerous kernel ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That worked! It is now spitting out the configs of each interface. Thank you!
It is a one element list…so you have one great big string stuffed inside the list.
When you loop through this, your loop variable
x
will be that great big string.You probably want to use
splitlines()
to break up the string i.e. instead of using .rstrip() do something like: