Hi guys, I've been struggling to create a script with condition whether $2 exist or not, so the logic is :
if $2 == ""
exit 1
if $2 == "email"
mail -s "test" ...
else
exit 1
how do I code it in ksh, I tried to code like above. But when I tried to execute the script, let's say the script name "check.ksh"
check.ksh 1 email --> it's running fine
check.ksh 1 -->
it said
./Check.ksh[48]: [: : unexpected operator/operand
./Check.ksh[48]: [: email: unexpected operator/operand
because I didn't put $2, how if I dont wanna put $2, but the script still running fine.
So the conclusion is
if I put $2 email --> email it
If I didn't put $2 --> don't do anything about command $2
Thx guys
if $2 == ""
exit 1
if $2 == "email"
mail -s "test" ...
else
exit 1
how do I code it in ksh, I tried to code like above. But when I tried to execute the script, let's say the script name "check.ksh"
check.ksh 1 email --> it's running fine
check.ksh 1 -->
it said
./Check.ksh[48]: [: : unexpected operator/operand
./Check.ksh[48]: [: email: unexpected operator/operand
because I didn't put $2, how if I dont wanna put $2, but the script still running fine.
So the conclusion is
if I put $2 email --> email it
If I didn't put $2 --> don't do anything about command $2
Thx guys