| Author |
Out;put is not getting in this Shell Script??
|
Madhu Kaparapu
Ranch Hand
Joined: Jul 04, 2005
Posts: 35
|
|
1) divisibility.sh ------------------- echo "Enter the number:\n" read x y=`expr $x % 3` z=`expr $x % 4` if [$y -eq 0 -a $z -eq 0] then echo "Divisible by both" elif [$y -eq 0] then echo "Divisible by 3 only" elif [$z -eq 0] then echo "Divibible by 4 only" else echo "Not by both" fi output: -------- divisibility.sh: line 5: [0: command not found divisibility.sh: line 8: [0: command not found divisibility.sh: line 11: [0: command not found Not by both ============================================== 2) greetings.sh ---------------- h=`date "+%H"` if [$h -gt 4 -a $h -lt 11] then echo "Good Morning" elif [$h -ge 11 -a $h -lt 16] then echo "Good Afternoon" elif [$h -ge 16 -a $h -lt 20] then echo "Good Evening" else echo "Good Night" fi output: ------- greetings.sh: line 2: [12: command not found greetings.sh: line 5: [12: command not found greetings.sh: line 8: [12: command not found Good Night i don't where the bug lies, i am using suse linux. please explaine me the correct way
|
Regards,
Madhu Kaparapu.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24048
|
|
Believe it or not, "[" is a UNIX program -- see /usr/bin/[ ! You have to use whitespace after its name, before its arguments, just as for all UNIX programs. So, for example,
|
[Jess in Action][AskingGoodQuestions]
|
 |
 |
|
|
subject: Out;put is not getting in this Shell Script??
|
|
|