Search code examples
bashshstdoutheredocoutput-redirect

Redirecting logs in shell script


Thanks for looking into my concern.

I have a piece of code inside my shell script as shown below and want to redirect logs of below script to a file. could you please help with it.

ssh -i /home/$cu/.ssh/${ssh_key}_rsa $Linux_User@$Linux_Machine <<EOF
{
source $HOME/.bashrc >/dev/null
chmod 777 -R ${Target_Dir}/Scripts/ >/dev/null
sh ${Target_Dir}/Scripts/tomcat.sh ${Target_Dir}
source $HOME/.bashrc >/dev/null
sh ${Target_Dir}/Scripts/appdeploy-multi.sh ${Target_Dir} $APP_VERSION $APP_NAME
sh ${Target_Dir}/Scripts/check-status.sh $APP_NAME
rm -rf ${Target_Dir}/
}
EOF

Solution

  • @cyrus/janos: Thank you so much. it fixed the thing.

    ssh ... <<EOF > file.log