Error on executing if statement in ssh command in unix shell scripting. Linux and sunos
#!/bin/bash
ssh u1@s1 "if [ $a == 100 ]
then
echo Hey that is a large number
pwd
fi
date"
Error: Ksh: test: argument expected
You'll get this if $a
is empty:
$ unset a
$ [ $a == 100 ] && echo one hundred || echo not
ksh: [: argument expected
not
Solution: quote the variable
$ [ "$a" == 100 ] && echo one hundred || echo not
not
Or use the double bracket conditional
$ [[ $a == 100 ]] && echo one hundred || echo not
not
I'm using ksh 93u+
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.