-1

I have a script:

echo "start"
cd ~/GoogleDrive/
drive push path-to-file/
echo "done"

which uploads path-to file to my Google Drive account. I can run this script without any problem by sh UploadToDrive.sh but when I try to execute it by means of double clicking on the script I get the error

start
/home/user/UploadToDrive.sh: 3: /home/user/UploadToDrive.sh: drive: not found
done 

I posted it here because it seems like Gnome is doing something wrong rather than there is something wrong with the script, as it works when I use sh or ./ explicitly. I am using Ubuntu 15.10 with Gnome 3, if it is relevant.

  • What if you put #!/bin/bash on top? – UniversallyUniqueID Apr 29 '16 at 13:00
  • Doesn't change anything. I get the same error. – Gonenc Mogol Apr 29 '16 at 13:03
  • How did you install this drive command? How is it added to the PATH? – muru Apr 29 '16 at 13:07
  • Exactly how it says here – Gonenc Mogol Apr 29 '16 at 13:09
  • What's the output of which drive and echo "$PATH" in your terminal. What's the output of echo "$PATH" from your script? – David Foerster Apr 29 '16 at 17:51
2

Since that .sh extension is only a hint for users (yep linux doesnt dance in the line of doing extension yada yada like windows) your script lacks as first a shebang line, so you script should look like this:

#!/bin/bash
echo "start"

#you might want to use explicit paths here this is why your script fails
cd /home/username/GoogleDrive/

#you might want to use explicit paths here this is why your script fails
drive push path-to-file/

echo "done"

After that change make sure your file has the proper permissions:

chmod 755 UploadToDrive.sh

And lastly enable execution within the GUI by going to the scripts properties:

file-properties

  • Well I've already allowed to be executed and I added the line above but the problem doesn't seem to go away. – Gonenc Mogol Apr 29 '16 at 13:05
  • did you as well chmod it ? – Videonauth Apr 29 '16 at 13:07
  • yup I did chmod it too – Gonenc Mogol Apr 29 '16 at 13:07
  • Have you tried a full path to 'drive'? @gonenc – bc2946088 Apr 29 '16 at 13:08
  • Revised my answer @gonenc – Videonauth Apr 29 '16 at 13:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.