Deepthz
November 23, 2010, 4:21am
1
ssh $USR@$host /bin/bash <<EOF
awk ' BEGIN{f=0} !f { s=$0; sub(/,.+/, "", s); gsub(/[-: ]/, " ", s); t=(systime()-mktime(s)); if(t<=14400) f=1 } f ' /home/error.log >> error.txt
EOF
We are trying to connect to a remote server through ssh and read values from error.log within last 4 hours.However, the output error.txt is created in the remote machine itself,but we wanted it in our local machine.
Scott
November 23, 2010, 4:43am
2
ssh $USR@$host /bin/bash <<EOF > error.txt
awk ' BEGIN{f=0} !f { s=$0; sub(/,.+/, "", s); gsub(/[-: ]/, " ", s); t=(systime()-mktime(s)); if(t<=14400) f=1 } f ' /home/error.log
EOF
Deepthz
November 23, 2010, 4:47am
3
But we have 3 awk commands like this:
ssh $USR@$host /bin/bash <<EOF
awk ' BEGIN{f=0} !f { s=$0; sub(/,.+/, "", s); gsub(/[-: ]/, " ", s); t=(systime()-mktime(s)); if(t<=14400) f=1 } f ' /logs/ship-error.log > ship-error.txt
awk ' BEGIN{f=0} !f { s=$0; sub(/,.+/, "", s); gsub(/[-: ]/, " ", s); t=(systime()-mktime(s)); if(t<=14400) f=1 } f ' /logs/inv-error.log > inv-error.txt
awk ' BEGIN{f=0} !f { s=$0; sub(/,.+/, "", s); gsub(/[-: ]/, " ", s); t=(systime()-mktime(s)); if(t<=14400) f=1 } f ' /logs/ord-error.log > ord-error.txt
EOF
In this case, how do we redirect .txt files to my local machine?
Scott
November 23, 2010, 4:55am
4
Sorry for not being a mind reader, but you only had one awk commaand!
scp the output files when your ssh is finished..
And please use code tags.