I'm trying to automate a server update process.
What this should do is check for git diff
files and list them, to later be copied from one place to the other.
Here's my script on my local machine:
update_frontend.sh
#!/bin/sh
ssh [login details] -t -t 'bash -s' < ~/Scripts/update_frontend_cmd.sh
update_frontend_cmd.sh
SOURCE=/var/www/git_front/mydir_front
TARGET=/var/www/front
dothis=
cd "$SOURCE"
for i in $(git diff --name-only origin/master master)
do
x=`echo $i | sed 's/mydir\///'`
dothis=`echo "
$dothis
cp './mydir/$x' '$TARGET/$x'"`
done
git pull
eval $dothis
Problem is, after any first input from me (be it login for git pull, or if I remove it, any other command I try to execute) causes the shell to hang. I just get a blank line an infinite waiting. Any idea what's causing this?
set -x
to the top of your script to trace its execution and to see where it stops.You shouldn't use single quotes around variables like$x
because then they will be literally expanded to$x
not the value ofx
.