<?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: TypeError: argument should be integer or bytes-like object, not 's in DevNet General Discussions</title>
    <link>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358367#M3016</link>
    <description>&lt;P&gt;I tried converting to a byte using the below updated code but still getting the same error which I have also placed below the code snippet.&lt;/P&gt;&lt;P&gt;import getpass&lt;BR /&gt;import sys&lt;BR /&gt;import telnetlib&lt;/P&gt;&lt;P&gt;HOST = "10.10.20.48"&lt;BR /&gt;user = input("Enter your telnet username: ")&lt;BR /&gt;password = getpass.getpass()&lt;BR /&gt;tn = telnetlib.Telnet(HOST)&lt;/P&gt;&lt;P&gt;tn.read_until("Username: ")&lt;BR /&gt;tn.write(user.encode('ascii') + b"\n")&lt;/P&gt;&lt;P&gt;if password:&lt;BR /&gt;tn.read_until("Password: ")&lt;BR /&gt;tn.write(password.encode('ascii') + b"\n")&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "/home/developer/pythonscript2.py", line 10, in &amp;lt;module&amp;gt;&lt;BR /&gt;tn.read_until("Username: ")&lt;BR /&gt;File "/usr/lib/python3.10/telnetlib.py", line 304, in read_until&lt;BR /&gt;i = self.cookedq.find(match)&lt;BR /&gt;TypeError: argument should be integer or bytes-like object, not 'str'&lt;/P&gt;</description>
    <pubDate>Wed, 31 Dec 2025 01:09:28 GMT</pubDate>
    <dc:creator>shawn-horne</dc:creator>
    <dc:date>2025-12-31T01:09:28Z</dc:date>
    <item>
      <title>TypeError: argument should be integer or bytes-like object, not 'str'</title>
      <link>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358305#M3014</link>
      <description>&lt;P&gt;I am trying to use a basic telnet script in python 3.9.11 to connect to a device in devnet sandbox.&amp;nbsp; The code is below:&lt;/P&gt;&lt;P&gt;import getpass&lt;BR /&gt;import sys&lt;BR /&gt;import telnetlib&lt;/P&gt;&lt;P&gt;HOST = "10.10.20.48"&lt;BR /&gt;user = input("Enter your telnet username: ")&lt;BR /&gt;password = getpass.getpass()&lt;/P&gt;&lt;P&gt;tn = telnetlib.Telnet(HOST)&lt;/P&gt;&lt;P&gt;tn.read_until("Username: ")&lt;BR /&gt;tn.write(user + "\n")&lt;BR /&gt;if password:&lt;BR /&gt;tn.read_until("Password: ")&lt;BR /&gt;tn.write(password + "\n")&lt;/P&gt;&lt;P&gt;After entering my password I am getting the following error:&lt;/P&gt;&lt;P&gt;TypeError: argument should be integer or bytes-like object, not 'str'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2025 15:27:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358305#M3014</guid>
      <dc:creator>shawn-horne</dc:creator>
      <dc:date>2025-12-30T15:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: argument should be integer or bytes-like object, not 's</title>
      <link>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358316#M3015</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/1906988"&gt;@shawn-horne&lt;/a&gt;&amp;nbsp;this is a classic Python 2 versus 3 issue. This is because&amp;nbsp;strings were handled as bytes by default in Python 2, but in Python 3, strings are Unicode. Per your errors these should be bytes, not strings.&lt;/P&gt;
&lt;P&gt;Your fix is to&amp;nbsp;&lt;SPAN&gt;you need to "encode" your string variables into bytes. Fix this and it will work fine.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;On a side note,&amp;nbsp;telnetlib is not longer supported after Python 3.11. Would suggest to move to Netmiko.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2025 16:24:22 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358316#M3015</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2025-12-30T16:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: argument should be integer or bytes-like object, not 's</title>
      <link>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358367#M3016</link>
      <description>&lt;P&gt;I tried converting to a byte using the below updated code but still getting the same error which I have also placed below the code snippet.&lt;/P&gt;&lt;P&gt;import getpass&lt;BR /&gt;import sys&lt;BR /&gt;import telnetlib&lt;/P&gt;&lt;P&gt;HOST = "10.10.20.48"&lt;BR /&gt;user = input("Enter your telnet username: ")&lt;BR /&gt;password = getpass.getpass()&lt;BR /&gt;tn = telnetlib.Telnet(HOST)&lt;/P&gt;&lt;P&gt;tn.read_until("Username: ")&lt;BR /&gt;tn.write(user.encode('ascii') + b"\n")&lt;/P&gt;&lt;P&gt;if password:&lt;BR /&gt;tn.read_until("Password: ")&lt;BR /&gt;tn.write(password.encode('ascii') + b"\n")&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;File "/home/developer/pythonscript2.py", line 10, in &amp;lt;module&amp;gt;&lt;BR /&gt;tn.read_until("Username: ")&lt;BR /&gt;File "/usr/lib/python3.10/telnetlib.py", line 304, in read_until&lt;BR /&gt;i = self.cookedq.find(match)&lt;BR /&gt;TypeError: argument should be integer or bytes-like object, not 'str'&lt;/P&gt;</description>
      <pubDate>Wed, 31 Dec 2025 01:09:28 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358367#M3016</guid>
      <dc:creator>shawn-horne</dc:creator>
      <dc:date>2025-12-31T01:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: TypeError: argument should be integer or bytes-like object, not 's</title>
      <link>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358414#M3017</link>
      <description>&lt;P&gt;Arh I see your issue, you&amp;nbsp;&lt;SPAN&gt;need to add a “b”&lt;/SPAN&gt;&lt;SPAN&gt;prefix to the search strings inside the read_until&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;methods. Then Python treats those strings as bytes constants.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Dec 2025 08:34:47 GMT</pubDate>
      <guid>https://community.cisco.com/t5/devnet-general-discussions/typeerror-argument-should-be-integer-or-bytes-like-object-not/m-p/5358414#M3017</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2025-12-31T08:34:47Z</dc:date>
    </item>
  </channel>
</rss>

