I am trying to create a script (test.sh) that logs on to another server and checks the disk usage of some different folders:
test.sh:
DIRS="dir_A dir_B dir_C"
for DIR in $DIRS
do
sshpass -p user_password ssh -o StrictHostKeyChecking=no user_name@host 'cd /opt/app/$DIR;SIZE=$(du -s);echo "YVALUE="$SIZE > ../size_$DIR.txt'
done
However, the variable DIR never gets passed to the script. It is empty when I run the script. I have tried using {} around $DIR but still no success. What am I missing? Thanks for your help!