I have the following command substitution in a command passed to a ssh host.
shpass -f /home/user/folder/password ssh o StrictHostKeyChecking=no user@host "/bin/grep INFO "$(find /app/logs/* -type f -name "catalina*.log" |grep -i batch | xargs ls -lrth | tail -1 | awk '{print $9}')" | /usr/bin/tail -10 > /home/user/folder/monitor/bcs01_batch_check_catalina.log; grep -i '\''Server startup in'\'' /home/user/folder/monitor/bcs01_batch_check_catalina.log | wc -l"
What I am trying to do is to grep INFO from the latest catalina log available on the host server that I am connecting with ssh. But the find command runs on my local host.
Expected result should be 1, as the file exists on the ssh host, but I am getting the following error message
********************************************************************
* *
* This system is for the use of authorized users only. Usage of *
* this system may be monitored and recorded by system personnel. *
* *
* Anyone using this system expressly consents to such monitoring *
* and is advised that if such monitoring reveals possible *
* evidence of criminal activity, system personnel may provide the *
* evidence from such monitoring to law enforcement officials. *
* *
********************************************************************
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file
I tried with putting the command
"$(find /app/logs/* -type f -name "catalina*.log" |grep -i batch | xargs ls -lrth | tail -1 | awk '{print $9}')"
between ``, also escape the " and $ characters, but still no success
\"\$(find /app/logs/* -type f -name "catalina*.log" | grep -i batch | xargs ls -lrth | tail -1 | awk '{print $9}')\"
It seems that the find command is ran locally, instead of the ssh host.
What can I do?
Thanks