Python Forum
decoding sub.process output with multiple \n? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: decoding sub.process output with multiple \n? (/thread-16324.html)



decoding sub.process output with multiple \n? - searching1 - Feb-23-2019

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


RE: decoding sub.process output with multiple \n? - buran - Feb-23-2019

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

>>> 



RE: decoding sub.process output with multiple \n? - searching1 - Feb-24-2019

@buran, Thanks it worked! :)