0

I'm trying to execute git commands from a bash script.

code:

#!/bin/bash  
echo "commit and push all files in this folder: "

INPUTPATH=""
FILENAME="README2"
PATH=""

if [ -s text.txt ]
then
    echo "file is not empty"

    INPUTPATH=$(<text.txt)
    #echo "$INPUTPATH"
else
          read INPUTPATH
   echo "$INPUTPATH" > text.txt

   
fi

PATH="$INPUTPATH/$FILENAME"
for run in {1..10}; do
echo $RANDOM >> $PATH
done
cd $INPUTPATH && git commit -am "commit"
cd $INPUTPATH  && git status

The script work's fine, besides the last two commands.

these are the error messages:

line 25: git: command not found line 26: git: command not found

torek
  • 448,244
  • 59
  • 642
  • 775
Flap13
  • 21
  • 6
  • either you do not have `git` installed or your script is not able to find the `git` executable when it runs. If you have installed it - Do a `which git` to get the absolute path of the executable and replace `git` with the output of the command. – leoOrion Dec 06 '21 at 06:41
  • It seems that git is not installed in your system. can you try command `which git` and paste the output – Sadaananth Anbucheliyan Dec 06 '21 at 06:41
  • Don't modify `$PATH`. – user202729 Dec 06 '21 at 06:42
  • You're setting the PATH variable, the PATH variable contains paths to where executable files/commands are located (such as the git command), don't reset it. – nos Dec 06 '21 at 06:45
  • It was the $PATH variable, thanks a lot – Flap13 Dec 06 '21 at 06:56

0 Answers0