Bash help
Hey there,
I'm new here and currently taking Bash Programming in college. I'm having a little problem right now with my code i'm trying to have my program output the date/time whenever a user inputs the word "time" when my program prompts them to enter something so far this is what the code looks like and I'm getting an integer expression expected Quote:
|
-eq is a numeric comparison.
You want either == (or = when used in an expression), also suggest space after the closing " on "time". Run down the bash manpage to "Conditional Expressions" |
that worked, thanks! I'll be back for more help soon, probably
question: with if statements, if you have an if inside an if, do you need a fi at the end of the inner if statement example: Quote:
|
Quote:
|
Ok,
so more problems. Here's my code: Quote:
Quote:
Quote:
|
And the question is?
|
Quote:
Code:
elif [ "$x" = "Directory" Code:
elif [ "$x" = "Directory" ] 2 of the 3 braces need spaces before the closing right bracket. time" ] and who" ] NOT time"] or who"] http://tldp.org/LDP/abs/html/testcon...ml#DBLBRACKETS |
Quote:
|
Quote:
You might want to have a look at these: Bash resources: |
thanks for the help and info druuna!
on the who command, how do you get each user to appear on their own line so its not all mashed up? |
Quote:
Code:
elif [ "$x" == "Who" ] You may also want to start indenting your if blocks, it makes larger codes infinitely easier to read. |
added another elif statement, because my assignment seems to contain a lot of them. Anyways, all my scripts are working except for the last elif statement.
This is the error I get when I execute the script using the "trigger" work if you will. Quote:
Quote:
|
Quote:
|
That was my bad on typing here. My script has "". Still have same error
|
Please post the complete script, or at least the complete if-then-elif-fi part that doesn't work. Also post the exact error it throws.
|
All times are GMT -5. The time now is 11:16 PM. |