LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-19-2020, 05:27 AM   #1
gehilpiku84
LQ Newbie
 
Registered: Oct 2020
Posts: 3

Rep: Reputation: Disabled
Saving colored output of a script


Hello everyone. I want your help. I'm making a tool using python and the output that I'm displaying is colored. It has horizontal lines, blue, green, red texts.... I wanted to know if there's any way I can save the output in a text file, or pdf format. I tried redirecting the output to a text file but it separates the black and white output and the colored output. Any solution?10.0.0.0.1 192.168.1.254

Last edited by gehilpiku84; 10-21-2020 at 05:37 AM.
 
Old 10-19-2020, 05:33 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,848

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
A regular text file may not contain color related info. So most probably I would try to create a html document (or similar) with that python script.
But without details hard to say more.
 
1 members found this post helpful.
Old 10-19-2020, 08:14 AM   #3
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by gehilpiku84 View Post
it separates the black and white output and the colored output. Any solution?
That's very interesting. Curiosity only: Do you actually see the colored output?

I'm not sure, but would tend to agree with pan64, a text file is likely too fundamental/simple to be able to represent that. But this is why I asked my curious question.

I'd try to find a way to write it to a PDF, HTML, or other type of document/image file which can show colors. I wrote "image" with hesitation. While that may be either easier vs not to accomplish, the issue there is if you wish the output file to be edit capable at the text level, then making it an image, or subsequently making it a PDF image, then you can only edit it as a image and not text.
 
Old 10-19-2020, 08:28 AM   #4
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,599

Rep: Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546Reputation: 2546
Quote:
Originally Posted by gehilpiku84 View Post
I tried redirecting the output to a text file but it separates the black and white output and the colored output.
That makes me wonder whether you're redirecting stdout but not stderr, and the latter is where the colours are being output.

Quote:
I'm making a tool using python and the output that I'm displaying is colored.
Show a simplified version of the code you're using to do this, (making sure that example still exhibits the issue you're describing).

 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Colored Output in mail by mailx mahendra singh Programming 2 08-18-2013 11:59 AM
Can script output be made colored? rng Linux - General 4 03-04-2012 06:59 PM
Colored output in Python MTK358 Programming 2 12-24-2009 08:01 PM
getting colored text output file using C ibabhelix Programming 2 11-04-2009 02:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration