Answer the question
In order to leave comments, you need to log in
How to write a BASH file correctly?
I do the same thing all the time
ssh -i /var/www/keys/my_key.pem [email protected] "cd /var/www/ && git fetch && git reset --hard origin/$1 && bash my_bash.sh"
Answer the question
In order to leave comments, you need to log in
run something like this:sh ./bash.sh my_branch
#!/bin/bash
ssh -i /var/www/keys/my_key.pem -f [email protected]
cd /var/www/
git fetch
git reset --hard origin/$1
bash my_bash.sh
cat <<EOF > bash.sh
#!/bin/bash
# Путь может быть другим -> whereis bash
case "$#" in
0)
# На входе ноль параметров, выполним ссш
ssh -i /var/www/keys/my_key.pem -f [email protected]
;;
1)
# На входе 1 параметр, выполним ссш и что-то еще
ssh -i /var/www/keys/my_key.pem -f [email protected]
cd /var/www/
git fetch
git reset --hard origin/$1
bash my_bash.sh
;;
*)
# На входе хрен пойми что - дай подсказаньку
echo "Usage: \"bash ./bash.sh my_branch\" OR \" bash ./bash.sh \" ";
;;
esac
EOF
ssh -i /var/www/keys/my_key.pem [email protected] "cd /var/www/ && git fetch && git reset --hard origin/$1 && bash my_bash.sh"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question