In my bash script I wish to ssh into a machine, and if the machine is down, perform something within an if statement.
To check whether or not the the machine is down I have an if statement using the -ne command which I use to compare the value returned by the ssh function ($? which is 255 if the ssh was unsuccessful) and 0.
However I get the following error
line 5: [0: command not found
Here is my code
#!/bin/bash
ssh blobbby
if [0 -ne $?]
then
echo "ssh not succesful"
fi
If someone can please explain what mistake I've made I would be most grateful.
https://stackoverflow.com/questions/4468824/command-not-found-when-attempting-integer-equality-in-bash#
– generic purple turtle Oct 30 '17 at 18:04