I'm running some code on a remote server over ssh but when i try to execute code to save to the variable 'APP' it will run before mounting the file and also do that on the local machine instead of the remote. What am i doing wrong?
ssh $TARGET_USER@$TARGET_IP << EOF
if [ ${PACKAGE: -4} == ".dmg" ]; then
hdiutil attach -mountpoint $MOUNTPOINT $FILE_STORE$PACKAGE
APP=`sudo find $MOUNTPOINT -maxdepth 2 -name \*.app | wc -l | tr -d ' '`
fi
EOF
Here is a cutdown version of my code, i want the variable APP to contain the number of lines 0 or 1 or more.