ssh $hname "cd /opt/tomcat/webapps/aware/WEB-INF/classes/com && for FNAME in `tar tvf /tmp/prop.tar | awk '{print $6}'`
do
if test ! -s "/tmp/$fname/prop_bkup.tar"
then
ls $FNAME && tar cvf /tmp/$fname/prop_bkup.tar $FNAME && rm $FNAME || echo "$FNAME is a new file".
else
ls $FNAME && tar uvf /tmp/$fname/prop_bkup.tar $FNAME && rm $FNAME || echo "$FNAME is a new file".
fi
done"
Above for loop is not working in remote host. Can anyone please help me on this?
I’ve edited you question to put the code into a code block. In the mean time, I can see a few potential problems:
shell filling in the variables. This will also be causing problems
with the double quotes in the remote command.
If you change to single quotes, you’ll need to make sure you’ve still quoted the
awkargument properly.$fnameand uppercase$FNAME– they should all be the same ($FNAMEin this instance).You need to explain what you mean by “not working”. This will give you much better answers.