Search code examples
pythonmacosshellterminalgoogle-code

Python Script Fails To Run When Launched From Shell File, But Works When Launched From Terminal


If I launch the Google Code upload Python script from Terminal, it works as expected, but when I launch it using the code below in a Bourne Shell Script file, it fails with the error "close failed in file object destructor: Error in sys.excepthook: Original exception was:".

#!/bin/sh
BUILD_FOLDER="/Users/James/Documents/Xcode Projects/Uber Sweep - Mac/build/Release & Package"

if [ -f "$BUILD_FOLDER/Uber Sweep (64 bit).zip" ]; then
python /Users/James/Scripts/Google\ Code\ Upload.py -s "Uber Sweep - Mac OS X (64 bit)" -p "uber-sweep" -u "EXCLUDED" -l "Featured,Type-Archive,OpSys-OSX" "$BUILD_FOLDER/Uber Sweep (64 bit).zip" | echo
fi

Why is this?

Thank you for your help,
jrtc27


Solution

  • echo doesn't accept anything from stdin, so it's doing nothing but outputting a blank line. The script's output should appear without having to do anything to it.

    Try specifying the full path to python. The PATH for the script may be different than it is for your interactive shell.

    You should be able to quote the name of your Python script and avoid the awkward escaping of spaces.