Skip to main content
added 21 characters in body
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Don't store the paths to the commands you're using in variables, it's totally unnecessary. If you are using tools under non-standard paths (which you don't do), modify $PATH instead.

You are using cat $check. Two things to note about this:

  1. $check will undergo field splitting on whitespace, turning it into a number of words. These will then undergo filename globbing if they contain filename globbing characters.

  2. The resulting words will be given to cat, which expects them to be filenames. This is where your error comes from.

Instead, just pipe the ssh to awk directly:

ssh [email protected] "/usr/local/bin/check_mq.sh" |
awk -F '=' '{ print $NF }'

This assumes you want to output the number after the last = on the line.

If you want to test whether this number is greater than some variable $x:

ssh [email protected] "/usr/local/bin/check_mq.sh" |
awk -F '=' -v x="$x" '$NF > x { printf("%d is more than %d\n", $NF, x) }'

Don't store the paths to the commands you're using in variables, it's totally unnecessary. If you are using tools under non-standard paths, modify $PATH instead.

You are using cat $check. Two things to note about this:

  1. $check will undergo field splitting on whitespace, turning it into a number of words. These will then undergo filename globbing if they contain filename globbing characters.

  2. The resulting words will be given to cat, which expects them to be filenames. This is where your error comes from.

Instead, just pipe the ssh to awk directly:

ssh [email protected] "/usr/local/bin/check_mq.sh" |
awk -F '=' '{ print $NF }'

This assumes you want to output the number after the last = on the line.

If you want to test whether this number is greater than some variable $x:

ssh [email protected] "/usr/local/bin/check_mq.sh" |
awk -F '=' -v x="$x" '$NF > x { printf("%d is more than %d\n", $NF, x) }'

Don't store the paths to the commands you're using in variables, it's totally unnecessary. If you are using tools under non-standard paths (which you don't do), modify $PATH instead.

You are using cat $check. Two things to note about this:

  1. $check will undergo field splitting on whitespace, turning it into a number of words. These will then undergo filename globbing if they contain filename globbing characters.

  2. The resulting words will be given to cat, which expects them to be filenames. This is where your error comes from.

Instead, just pipe the ssh to awk directly:

ssh [email protected] "/usr/local/bin/check_mq.sh" |
awk -F '=' '{ print $NF }'

This assumes you want to output the number after the last = on the line.

If you want to test whether this number is greater than some variable $x:

ssh [email protected] "/usr/local/bin/check_mq.sh" |
awk -F '=' -v x="$x" '$NF > x { printf("%d is more than %d\n", $NF, x) }'
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

Don't store the paths to the commands you're using in variables, it's totally unnecessary. If you are using tools under non-standard paths, modify $PATH instead.

You are using cat $check. Two things to note about this:

  1. $check will undergo field splitting on whitespace, turning it into a number of words. These will then undergo filename globbing if they contain filename globbing characters.

  2. The resulting words will be given to cat, which expects them to be filenames. This is where your error comes from.

Instead, just pipe the ssh to awk directly:

ssh [email protected] "/usr/local/bin/check_mq.sh" |
awk -F '=' '{ print $NF }'

This assumes you want to output the number after the last = on the line.

If you want to test whether this number is greater than some variable $x:

ssh [email protected] "/usr/local/bin/check_mq.sh" |
awk -F '=' -v x="$x" '$NF > x { printf("%d is more than %d\n", $NF, x) }'