I want to grab relevant lines out of an SNMP logger in real-time and move them over to my application server for checking. The second half is fine,
scp is doing the trick. The first half is causing me some grief.
What I want to do is check the three latest log files for the relevant messages.
So I'd do:
[user@SNMPServer]$ cd /var/opt/OV/log/nnm/; files=`ls -t | grep -m 3 trap.csv`; echo $files
trap.csv trap.csv.2019-05-31_07_00_01 trap.csv.2019-05-31_06_00_01
Which is great, because I then plan to:
[user@SNMPServer]$ grep $ipAddress $files
Which again, works fine when I run it on the SNMP server.
When I do it from my VM However,
admin@alarmux:~$sudo ssh firstname.lastname@example.org "cd /var/opt/OV/log/nnm/; files=`ls -t | grep -m 3 trap.csv`; echo $files"
I get this output:
bash: testerlog: command not found
bash: count.txt: command not found
These are the
ls -t results from my VM's home directory, not the remote one.
Am I missing escape characters somewhere?