Search code examples
pythonimagescanningos.system

Python: os.system() redirecting stdout to file in home directory fails


I used the following command :

os.system('scanimage > ~/test.pnm')

but I can't find the image.

Any suggestions?


Solution

  • Maybe ~ is not expanded. Try

     os.system("scanimage > $HOME/test.pnm")
    

    and

     os.system("scanimage > /tmp/test.pnm")
    

    Or if you are running as a different UNIX user (root) the home is not what you expect.