python: how to pass output of system commands to variable
I'm trying to write a python script that will use the current user's name when interacting. Ex: when started, it should say "hello daweefolk" when I am logged in.
I've tried Code:
username=os.system("echo $USER") What is the correct code? |
You can try os.environ, e.g.
Code:
username = os.environ.get("USER") |
All times are GMT -5. The time now is 05:55 AM. |