syntax error near unexpected token `then'
Hi,
I'm trying to build a script for adding existing local Users to LDAP Directory, but i have an error: Code:
adduser.sh: line 12: syntax error near unexpected token `then' Code:
#!/bin/bash if[...]; then ............... Maybe, help me for a script Thanks all! |
I haven't got any error messages.
try bash -vx adduser.sh to check what was going wrong. Which version of bash did you try? |
Quote:
Here is version after commmand sh --version Code:
GNU bash, version 4.1.2(1)-release (i368-redhat-linux-gnu) Code:
#!/bin/bash |
Both worked for me:
GNU bash, version 3.2.51(1)-release (x86_64-suse-linux-gnu) GNU bash, version 4.2.25(1)-release (x86_64-pc-linux-gnu) I assume you have some hidden char(s) in the file (probably you edited it on windows?). You can try od -cx adduser.sh to check it. |
Quote:
thanks for your recommend, but i can't solve this error, hmmm |
have you checked for the 'hidden char(s)' ?
Code:
od -cx adduser.sh or Code:
cat -A adduser.sh or anything you don't recognise |
Quote:
thanks for your comment, and i checked for hidden char(s) Code:
cat -A adduser.sh Code:
#!/bin/bash $ can you check errors, Firerat? thanks! |
It looks ok...
I cannot find the reason, but you can try to insert the following line before if [ ! "$NAME" ] echo "processing: $NAME." and please run the script and post the result |
like pan64, it looks fine to me
I've copied your script, including tabs ( the ^I indicate tabs ) and it works fine for now, at least, I'm lost... |
It is about " ' ` usually. Try to avoid use ` at all, like:
Code:
DATE=$(date -s) |
fixed FLAG, had hangover $UID1
or bash
Code:
#!/bin/bash probably needs tweaking |
Quote:
i tried to insert this line before if....... but this error isn't solved hmm, sorry for not reply you soon, pan and i need your help, thanks for your interest in my thread |
Quote:
ok i will try your script, and i'll post the result early Thanks Fire,hi |
Quote:
|
Quote:
this is result when i add a line Code:
echo "processing: $NAME" Code:
adduser.sh: line 13: syntax error near unexpected token `then' hmm, i can understand what you say, but i speak and write English not very well |
All times are GMT -5. The time now is 08:17 AM. |