I am trying to write a set of bash commands into a shell script file which will then be executed on a server.
It works fine up until the point at which I want to write a diff command into a script file that is then expected to be executed and have the console output written into a *.txt file. For some reason, the *.txt file doesn't include the diff results... anything I can do to fix this?
A_DIR_1=methuselah/test1
A_DIR_2=methuselah/test2
A_DIR_3=methuselah/test3
B_DIR_1=methuselah/backup1
B_DIR_2=methuselah/backup2
B_DIR_3=methuselah/backup3
DST_DIR=methuselah/output
echo "touch $DST_DIR/output.txt" >> /tmp/$$.sh
for i in {1..3}
do
A_DIR="A_DIR_$i"
B_DIR="B_DIR_$i"
echo "diff -qr ${!A_DIR} ${!B_DIR} >> $DST_DIR/output.txt" >> /tmp/$$.sh
done
cat /tmp/$$.sh
ssh meth@$SERVER 'sh -s' < /tmp/$$.sh
rm /tmp/$$.sh