Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm quite new to bash, so I'm sorry if I'm asking something silly. Long story short, I'm trying to run the following bash script:

#!/bin/sh

ACTION="init" # init or push
USERNAME="username"
PASSWORD="password"
HOST="host.com"
PATH="WebSite/app"
DRYRUN="-D" # use -D for dry-run

cd ./htdocs/app/

git checkout master # switch to master
git push # push to origin
git ftp $ACTION --user $USERNAME --passwd $PASSWORD $DRYRUN ftp://$HOST/$PATH

but when I do, I get the following error:

deploy.sh: line 12: git: command not found
deploy.sh: line 13: git: command not found
deploy.sh: line 14: git: command not found

If I were to follow the steps in the script directly myself, it works as intended, but not when running via bash.

I think it might have something to do with git not being in my $PATH, which looks like this: /home/daniel/.rvm/gems/ruby-1.9.3-p286/bin:/home/daniel/.rvm/gems/ruby-1.9.3-p286@global/bin:/home/daniel/.rvm/rubies/ruby-1.9.3-p286/bin:/home/daniel/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/daniel/.rvm/bin but if that is the case, then I'm not sure how to add it.

Can someone help? Thank you :)

share|improve this question

migrated from stackoverflow.com Nov 18 '12 at 1:41

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 5 down vote accepted

You've overwritten your PATH in your script. Don't overwrite it, just append "WebSite/app" to your PATH:

PATH=$PATH:"WebSite/app"

share|improve this answer
    
Whoops, so I have. I've changed both references to PATH in my script to REMOTEPATH, and it's now working as intended. Thank you. –  Daniel Hollands Nov 17 '12 at 15:11

PATH=$PATH:"WebSite/app"
this should help

share|improve this answer
  1. find out where the git executable is so: which git

  2. if which returns ERROR ($? = 1), then git is not in your PATH

  3. find out where you installed it.

  4. replace git in your script with path_to_git/git, or modify PATH

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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