Need help with ssh quiet mode
I'm trying to run a pretty lengthy command in my perl script using ssh -q function but it doesn't accept the command as it gives error:
bash: syntax error near unexpected token '('
Command I'm trying to run is:
ssh -q hostname 'stats1.pl stats:dat | grep data | grep -w 0 | awk '{system("cat /opt/jhh/etc/configuration.xml | grep "$1)}' | awk -F"=" '{print $6}' | awk '{print $1}' | sed 's/>//g' | tr -d '"''
I can give a short explanation about why I need such a lengthy command:
I will receive a output here:
stats1.pl stats:dat | grep data | grep -w 0
61574 | hostname_A | data | 1 | N/A | 0
61575 | hostname_A | data | 1 | N/A | 0
Only the items matching data and has 0 will list there.
Then I want 61574 & 61575 to be searched in a configuration file and get the output which is why I use the below:
stats1.pl stats:dat | grep data | grep -w 0 | awk '{system("cat /opt/jhh/etc/configuration.xml | grep "$1)}'
Output I will receive like:
device="61574" name="hostname_A" ip="127.0.0.1" platform="Cisco" protocol="tcp" user="admin"
device="61575" name="hostname_A" ip="10.0.0.1" platform="Cisco" protocol="tcp" user="admin"
Here I want to know the platform hence using the command stats1.pl stats:dat | grep data | grep -w 0 | awk '{system("cat /opt/jhh/etc/configuration.xml | grep "$1)}' | awk -F"=" '{print $6}' | awk '{print $1}' | sed 's/>//g' | tr -d '"'
this will give me below result:
cisco
cisco
Any help here is appreciated as I'm struck without able to execute this via script.
I'm seeing the error below. I'm afraid even if I manage to correct the below error it will prompt more and I need a solution to execute this command via Quiet mode.
[karthik4455@mastghg ~]$ ssh -q hostname 'stats1.pl stats:dat | grep data | grep -w 0 | awk '{system("cat /opt/jhh/etc/configuration.xml | grep "$1)}' | awk -F"=" '{print $6}' | awk '{print $1}' | sed 's/>//g' | tr -d '"''
bash: syntax error near unexpected token '('
Best Regards,
Karthik
|