Click to See Complete Forum and Search --> : shell scripting question - whats wrong


RedHat123
03-12-2004, 12:07 AM
#!/bin/bash
vartest="hello"
echo $vartest


runing the script with bash ./test.sh
i get


hello
: command not found


why is (:command not found) in the output ?

bwkaz
03-12-2004, 08:09 PM
I'd guess that it's because you have some mismatched quoting going on somewhere. I think it's actually saying hello<end-of-line>: command not found, as in the command that it's trying to run was hello followed by an end of line. To find out, you can redirect the standard output to /dev/null, because errors go to the standard error. If bash ./test.sh >/dev/null still shows "hello", then it's part of the error. If not, it's part of your script's output.

Make sure the quotes are indeed double quotes, and not backticks.

Make sure that all quotes that you open on a line are closed (and properly nested) on that line.

Anyway, there's either something different about your version of bash, or there's some difference between what you typed in here and what you have in your test.sh script. Because I can type what you have in here, and on my machine I get the expected output. :)

Edit: Never mind, I see you've double posted this question. This is what happens when people do that -- somebody takes the time to try to figure out what the issue is in the first thread, but meanwhile the problem's been solved in another one already.

Please do not double post. Thank you.