Scenario:
I have a script to connect to remote hosts and grep specific keyword from a log file. Without using EOF the ssh was getting freezed but when used heredoc (EOF) that issue was gone. All my commands have to be executed after ssh to remote host and hence they are within the EOF block.
grep command is giving me output as : 'No such file or directory' whereas I executed the same command on terminal and it gives desired output.
Below is the piece of code with problematic grep:
ssh -q -T username@remotehost <<-EOF 2>&1 | tee -a
getValue=$(grep -R 'keyword' /user/log/file.log | awk -F ' ' '{print$NF}') )
echo "${getValue}"
EOF
Output: grep: /user/log/file.log : No such file or directory
SSH is working fine as I printed the remote host and further cross checked the log path and file.log. From setup perspective everything is in place. Did some R&D over internet but nothing helped so far.