Bash script unexpected operator
Script output
Quote:
Script code: Code:
echo "-----------Select (em) or (e) or (cm)---------" |
Try putting set -xv at the top of the script and see what is actually being processed.
|
Always verify your test criteria first. Since I don't know what lines 24 and 27 exactly are in your script, I can't say anything specific about them.
Why does it show something appearing to be root password being entered? You should not be running scripts as root, and if there's a command in that script requiring root privileges, then you should be using sudo. I'm guessing that the unexpected operator has more to do with your call to mplayer versus your test, because if you examine the tests, they work. Consider using elif. Consider using exit a bit less: Code:
#!/bin/sh Code:
~/testcode$ mplayer.sh |
Quote:
So may be it is something related with mplayer. |
Try using "=" instead of "==".
"unexpected operator" is not a bash error message. However dash gives that message if '==' is used instead of '=' in a test. Bash supports '==' but dash doesn't. If dash is the default shell and the script was started with sh then the script will be running in dash, not bash. Error message strings can be extracted from shells with od Code:
# dash contains "unexpected operator" Code:
# bash does not contain "unexpected operator" |
you were probably right, i did:
[ $variable = value ] instead of: [ "$variable" == "value" ] and started working |
If you wish to keep formatting so everyone can see the difference in what you have typed, you will need to use [code][/code] tags around your code / data.
Remember to mark as SOLVED once you have a solution. |
All times are GMT -5. The time now is 11:11 PM. |