I get syntax error from awk command when querying a remote server
Good day.
This query on a local host works just fine: Code:
-bash-4.2$ df -P | awk '0+$5 >=40 {print}' Code:
-bash-4.2$ ssh -q 192.168.210.20 "df -P | awk '0+$5 >=40 {print}'" Please advise. Bjoern |
Quote:
Code:
ssh -q 192.168.210.20 "df -P" | awk '0+$5 >=40 {print}' |
Quote:
Your command works, but please allow me to expand on my issue. When I add a command to identify the remote host (uname -n), it prints the remote host name but then performs the 'df -P' on the local host. Note the hostnames are correct, but the numbers are all identical: Code:
-bash-4.2$ for scf in {20..73} ; do ssh -q -o "StrictHostKeyChecking no" 192.168.210.$scf uname -n;df -P | awk '0+$5 >= 40 {print}';done Bjoern |
Code:
for scf in {20..73} ; do Code:
"uname -n && df -P" | awk '0+$5 >= 40 {print}' The problem with formatting like this is harder to find problems imo. Code:
for scf in {20..73} ; do ssh -q -o "StrictHostKeyChecking no" 192.168.210.$scf uname -n;df -P | awk '0+$5 >= 40 {print}';done Code:
for scf in {20..73} ; do |
To elaborate on the others post
Code:
do ssh -q -o "StrictHostKeyChecking no" 192.168.210.$scf "uname -n;df -P" | awk '0+$5 >= 40 {print}';done Code:
do ssh -q -o "StrictHostKeyChecking no" 192.168.210.$scf "uname -n;df -P | awk '\$5>=40 {print}'";done |
May I humbly suggest df --output=pcent instead of df -P?
Code:
ssh ... 'uname -n;df --output=pcent'|awk 'NR==1||0+$0>=40' |
Quote:
Neat solution, but it only displays column 5 when I need the whole line to identify the partion: Code:
ssh -q -o "StrictHostKeyChecking no" 192.168.210.$scf 'uname -n;df --output=pcent'|awk 'NR==1||0+$0>=40';done;echo;fi |
Quote:
Your solution works, however, it also caught the 9% of the /var mount: Code:
-bash-4.2$ for scf in {20..73} ; do echo;ssh -q -o "StrictHostKeyChecking no" 192.168.210.$scf "uname -n;df -P | awk '\$5>=40 {print}'";done Code:
-bash-4.2$ for scf in {20..73} ; do echo;ssh -q -o "StrictHostKeyChecking no" 192.168.210.$scf "uname -n;df -P | awk '0+\$5>=40 {print}'";done Bjoern |
An alternative:
Code:
for scf in {20..73} |
Quote:
Bjoern |
Quote:
|
All times are GMT -5. The time now is 02:29 PM. |