[bash] having trouble debugging this bash script.
hello all.
im pretty new to bash and I was wondering if you could give me a pointer with this script: ------------- Code:
#!/bin/bash Code:
injection_protection.sh: line 65: syntax error near unexpected token `else' |
I bet the troublesome line is the following from your case-statement:
Code:
cat << "" > ${PATHCONF}/vhost.conf Looks to me like you rather want the subshell doing `cat <<-EOFM8...' in there... |
Hi,
I (and probably bash) don't understand what you are trying to to with this line: cat << "" > ${PATHCONF}/vhost.conf If you want to empty the file, just do: > ${PATHCONF}/vhost.conf Hope this helps. |
thanks, that'd done it.
:) |
Since the error refers to line numbers, it would be easier for use to examine the code if you used "cat -n script.sh" to add line numbers. It would also allow us to refer to linenumbers in answers.
Also, using indentation would help us understand the logic. The if's/then's/fi's are spread out and are easy to loose track of: Code:
1 #!/bin/bash Code:
if something Code:
if [ ! "`ls -l $PATHCONF | grep vhost.conf`" = "" ]; then Code:
if [ -f $PATHCONF/vhost.conf ] Code:
21 if [ ! "`ls -l $VHOSTROOT | grep $DOMAIN`" = "" ] From the look at it it seems that the if/then/else/fi statements balance out but not the way you want. You have the if inside the case construct and the corresponding else outside of it. Since ") > ${PATHCONF}/vhost.conf" will overwrite vhost.conf anyway, you don't need Code:
30 case "$yesno" in Code:
else if vhost.conf exists read yesno case yesno in [yY]) exit; esac create vhost.conf |
All times are GMT -5. The time now is 03:53 AM. |