Python Forum

Full Version: decoding sub.process output with multiple \n?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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

>>> 
@buran, Thanks it worked! :)