5

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 :)

1
  • I'm facing same issue while building CI Bamboo client. This saying log: command not found for following command gitlog=git log ${bamboo.planRepository.previousRevision}..${bamboo.planRepository.revision} Any suggestion ?
    – CoDe
    Feb 8, 2017 at 9:58

3 Answers 3

10

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

PATH=$PATH:"WebSite/app"

2
  • 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. Nov 17, 2012 at 15:11
  • wow... thanks stranger
    – thomas
    Jul 30, 2021 at 18:43
0

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

0
  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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .