I am trying to connect to server B from server A using ssh and executing commands using some other user.
However,
when I try searching for a pattern in log file it says "cannot open log file"
below is the sample code

```
ssh  -t user@hostname <<EOF
sudo su - someotheruser
a=`tail -10 /somepath/application.log | awk '/Agent Exited/ { print $3 }'`
if [ $a -eq 0 ] 
then
echo "Success"
else
echo "Failure"
fi 
EOF

```

once I run the script,
it says, `unable to open "tail........."`

I can't stay logged in on server B and run multiple commands.