Python Forum
decoding sub.process output with multiple \n?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
decoding sub.process output with multiple \n?
#1
Hi, I have created a script using sub.process then after reading I got this output (not in order) and \n new line exist on the output. How can we fix this, tried striping or decoding but I'm having typeerror issue or decode not supported issue.

Example of the output:
b'interface HundredGigE0/2/0/0\n description CUSTOMER;AS222;6521;T326;10Mb;ORr23;GE CUstomer;ID;location;system;Man;time;new;\n load-interval 30\n flow ipv4 monitor NETFLOW_MONITOR sampler NETFLOW_SAMPLER ingress\n

Seem like the \n newline doesnt work?

Still searching how to decode this. Thanks
Reply
#2
what exactly do you try and not work? What do you want to get?
>>> output=b'interface HundredGigE0/2/0/0\n description CUSTOMER;AS222;6521;T326;10Mb;ORr23;GE CUstomer;ID;location;system;Man;time;new;\n load-interval 30\n flow ipv4 monitor NETFLOW_MONITOR sampler NETFLOW_SAMPLER ingress\n'
>>> output.decode()
'interface HundredGigE0/2/0/0\n description CUSTOMER;AS222;6521;T326;10Mb;ORr23;GE CUstomer;ID;location;system;Man;time;new;\n load-interval 30\n flow ipv4 monitor NETFLOW_MONITOR sampler NETFLOW_SAMPLER ingress\n'
>>> print(output.decode())
interface HundredGigE0/2/0/0
 description CUSTOMER;AS222;6521;T326;10Mb;ORr23;GE CUstomer;ID;location;system;Man;time;new;
 load-interval 30
 flow ipv4 monitor NETFLOW_MONITOR sampler NETFLOW_SAMPLER ingress

>>> 
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
@buran, Thanks it worked! :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Decoding lat/long in file name johnmcd 4 270 Mar-22-2024, 11:51 AM
Last Post: johnmcd
  Enigma Decoding Problem krisarmstrong 4 633 Dec-14-2023, 10:42 AM
Last Post: Larz60+
  json decoding error deneme2 10 3,400 Mar-22-2023, 10:44 PM
Last Post: deanhystad
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,046 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  geojson to json --missing multiple row output yoshi 9 2,655 Mar-06-2022, 08:34 PM
Last Post: snippsat
  Run multiple process using subprocess Shiri 3 3,731 Nov-28-2021, 10:58 AM
Last Post: ghoul
  Process multiple pdf files Spartan314 1 1,297 Oct-27-2021, 10:46 PM
Last Post: Larz60+
  flask app decoding problem mesbah 0 2,312 Aug-01-2021, 08:32 PM
Last Post: mesbah
  Decoding a serial stream AKGentile1963 7 8,339 Mar-20-2021, 08:07 PM
Last Post: deanhystad
  Defining multiple functions in the same def process sparkt 5 2,753 Aug-09-2020, 06:19 PM
Last Post: sparkt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020