<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: AttributeError: 'list' object has no attribute 'rstrip' in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066117#M2160</link>
    <description>&lt;PRE&gt;with open('command.txt') as c:
    cmd = c.readlines()
# print cmd to see the output
print(cmd)

for c in cmd:
    # use strip on a single command before send to the device
    output = net_conn.send_command(c.strip('\r\n'))
    print(output)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-04-15 at 07.31.56.png" style="width: 908px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/71722i2849F3600FF7E7C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2020-04-15 at 07.31.56.png" alt="Screenshot 2020-04-15 at 07.31.56.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 06:34:08 GMT</pubDate>
    <dc:creator>omz</dc:creator>
    <dc:date>2020-04-15T06:34:08Z</dc:date>
    <item>
      <title>AttributeError: 'list' object has no attribute 'rstrip'</title>
      <link>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066030#M2158</link>
      <description>&lt;P&gt;This is my code&lt;/P&gt;&lt;PRE&gt;from netmiko import ConnectHandler

cisco_device = {
'device_type': 'cisco_ios',
'ip': 'R1',
'username': 'u',
'password': 'p'
}

with open('command.txt') as c:
cmd = c.read().splitlines()

net_connect = ConnectHandler(**cisco_device)
output = net_connect.send_command(cmd)
print(output)&lt;/PRE&gt;&lt;P&gt;command.txt&lt;/P&gt;&lt;PRE&gt;show clock
show version | include IOS&lt;/PRE&gt;&lt;P&gt;output&lt;/P&gt;&lt;PRE&gt;user@linux:~$ python script.py
Traceback (most recent call last):
File "script.py", line 14, in &amp;lt;module&amp;gt;
output = net_connect.send_command(cmd)
File "/home/user/.local/lib/python3.7/site-packages/netmiko/utilities.py", line 347, in wrapper_decorator
return func(self, *args, **kwargs)
File "/home/user/.local/lib/python3.7/site-packages/netmiko/base_connection.py", line 1378, in send_command
command_string = self.normalize_cmd(command_string)
File "/home/user/.local/lib/python3.7/site-packages/netmiko/base_connection.py", line 1532, in normalize_cmd
command = command.rstrip()
AttributeError: 'list' object has no attribute 'rstrip'
user@linux:~$&lt;/PRE&gt;&lt;P&gt;What should I do to fix this problem?&lt;/P&gt;&lt;P&gt;I tried to change `splitlines` to `split`, but it didn't change anything. Still getting the same error.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 04:30:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066030#M2158</guid>
      <dc:creator>write_erase</dc:creator>
      <dc:date>2020-04-15T04:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: 'list' object has no attribute 'rstrip'</title>
      <link>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066061#M2159</link>
      <description>The first operation is - &lt;BR /&gt;cmd = c.read().splitlines()&lt;BR /&gt;Which essentially splits a string into a list. And then you are trying - &lt;BR /&gt;output = net_connect.send_command(cmd)&lt;BR /&gt;&lt;BR /&gt;cmd is a list and not a individual command and so the error. Ideally, you should iterate over the items - &lt;BR /&gt;&lt;BR /&gt;for command in cmd:&lt;BR /&gt;  print(net_connect.send_command(command))</description>
      <pubDate>Wed, 15 Apr 2020 05:17:37 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066061#M2159</guid>
      <dc:creator>Manoj Papisetty</dc:creator>
      <dc:date>2020-04-15T05:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: 'list' object has no attribute 'rstrip'</title>
      <link>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066117#M2160</link>
      <description>&lt;PRE&gt;with open('command.txt') as c:
    cmd = c.readlines()
# print cmd to see the output
print(cmd)

for c in cmd:
    # use strip on a single command before send to the device
    output = net_conn.send_command(c.strip('\r\n'))
    print(output)&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2020-04-15 at 07.31.56.png" style="width: 908px;"&gt;&lt;img src="https://community.cisco.com/t5/image/serverpage/image-id/71722i2849F3600FF7E7C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2020-04-15 at 07.31.56.png" alt="Screenshot 2020-04-15 at 07.31.56.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 06:34:08 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066117#M2160</guid>
      <dc:creator>omz</dc:creator>
      <dc:date>2020-04-15T06:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: 'list' object has no attribute 'rstrip'</title>
      <link>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066147#M2161</link>
      <description>&lt;P&gt;Both solution works! Thanks. I wish i can accept both answers.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:15:27 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4066147#M2161</guid>
      <dc:creator>write_erase</dc:creator>
      <dc:date>2020-04-15T07:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: 'list' object has no attribute 'rstrip'</title>
      <link>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4267914#M2162</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Your Code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;net_connect = ConnectHandler(**cisco_device)
output = net_connect.&lt;STRONG&gt;send_command(cmd)&lt;/STRONG&gt;
print(output)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp; Another solution:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;net_connect = ConnectHandler(**cisco_device)
output = net_connect.&lt;STRONG&gt;send_config_set(cmd)&lt;/STRONG&gt;
print(output)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;It work, at least in my case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 17:06:57 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/attributeerror-list-object-has-no-attribute-rstrip/m-p/4267914#M2162</guid>
      <dc:creator>dominbajo07</dc:creator>
      <dc:date>2021-01-06T17:06:57Z</dc:date>
    </item>
  </channel>
</rss>

