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
  interactive process for input and output maiya 1 568 Mar-27-2025, 08:40 AM
Last Post: Gribouillis
  Decoding lat/long in file name johnmcd 4 1,554 Mar-22-2024, 11:51 AM
Last Post: johnmcd
  Enigma Decoding Problem krisarmstrong 4 2,174 Dec-14-2023, 10:42 AM
Last Post: Larz60+
  json decoding error deneme2 10 8,198 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 2,104 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  geojson to json --missing multiple row output yoshi 9 5,260 Mar-06-2022, 08:34 PM
Last Post: snippsat
  Run multiple process using subprocess Shiri 3 6,675 Nov-28-2021, 10:58 AM
Last Post: ghoul
  Process multiple pdf files Spartan314 1 1,834 Oct-27-2021, 10:46 PM
Last Post: Larz60+
  flask app decoding problem mesbah 0 3,226 Aug-01-2021, 08:32 PM
Last Post: mesbah
  Decoding a serial stream AKGentile1963 7 12,938 Mar-20-2021, 08:07 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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