I'm having some trouble with the != section of the if statement. Essentially this statement is valid as far as I'm aware, however executing this gives [: 1: !=: unexpected operator
. I've tried executing using -n but for whatever reason, even if the output is blank, using -n still runs the echo command.
Any help on this is appreciated. I've attached the code snippet below.
#!/bin/sh
HOST=$1
USER="/scripts/whoowns $HOST | tr -d '\r'"
ssh -t $HOST -p 22 -l deehem "sh -c 'if [ "" != "\`$USER\`" ]; then echo "Username for $HOST: \`$USER\`"; fi' ; bash -login"
"" != "$VAR"
?