I am trying to run some shell scripts from python, logging the stdout to a text file.
I tried to run the following dummy example. It works fine when I run the command from terminal, but writes an empty file when I call it from python.
Any idea why is that happening?
Shell Script: (~/shell_test)
echo "hello"
Command Call: (Works as expected from the terminal - shell_test_output.txt is created and "hello" is printed)
cd ~ && ./shell_test &>~/shell_test_output.txt
Python: (shell_test_output.txt is written as empty file)
os.system("cd ~ && ./shell_test &>~/shell_test_output.txt")