Python Forum
subprocess.call change color of shell
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
subprocess.call change color of shell
#1
Hello there,
I am using the package 'subprocess' to call some programs with parameter shell=True. Now I wish to change the color of the produced output. My system is Linux Ubuntu 15 with python3.5

Can someone help me?
My latest approach:
import subprocess

print("Some text in default color.")
subprocess.run(['echo -e "\033[32m"', 'ls -l', 'echo -e "\033[0m"'], shell=True)
print("Hopefully some text in default color, again.")
Produces:
Output:
Some text in default color. -e Hopefully some text in default color, again. <- this is now green Process finished with exit code 0
I want something like this:
Output:
Some text in default color. #from now on in green total 2088 -rw-rw-r-- 1 aq aq    1990 Sep 29 22:08 bibtexCheck.py -rw-rw-r-- 1 aq aq 1936333 Jan 10 10:23 argparse #from now on in default color Hopefully some text in default color, again.
Thanks a lot,
Aquaplant
Reply


Messages In This Thread
subprocess.call change color of shell - by Aquaplant - Jan-17-2017, 02:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 3,748 Oct-25-2023, 09:09 AM
Last Post: codelab
  simplekml change shape&color issac_n 2 4,280 Aug-20-2022, 07:15 PM
Last Post: Joseph_Paintsil
  continue if 'subprocess.call' failes tester_V 11 9,989 Aug-26-2021, 12:16 AM
Last Post: tester_V
  printing out the contents aftre subprocess.call() Rakshan 3 4,259 Jul-30-2021, 08:27 AM
Last Post: DeaD_EyE
  subprocess call cannot find the file specified RRR 6 22,073 Oct-15-2020, 11:29 AM
Last Post: RRR
  Change the color automatically Dragonos 5 4,196 Jul-28-2020, 01:17 PM
Last Post: Dragonos
  Use of input function to change screen background color in Turtles Oldman45 3 8,635 Jul-10-2020, 09:54 AM
Last Post: Oldman45
  Why wont subprocess call work? steve_shambles 3 3,848 Apr-28-2020, 03:06 PM
Last Post: steve_shambles
  subprocess.call - Help ! sniper6 0 1,986 Nov-27-2019, 07:42 PM
Last Post: sniper6
  How to use subprocess send commands to windows shell hlhp 3 6,343 Nov-26-2019, 04:40 AM
Last Post: LeanbridgeTech

Forum Jump:

User Panel Messages

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