I've been getting this weird syntax error no matter what I do, and I'm pretty stumped. I was wondering if you guys had any suggestions? I've tried a couple variant. I'll list their errors and code.
Here is the first variant:
Code:
#!/bin/bash
if /bin/grep -e $1 /etc/passwd > /dev/null
HOMEDIR="$( /bin/grep -e ^$1 /etc/passwd | cut -d: -f6 )"
CURSH="$( /bin/grep -e ^$1 /etc/passwd | cut -d: -f7 )"
echo "$CURSH"
echo "$HOMEDIR"
exit;
else
echo "No Such User Here."
exit;
fi
exit;
And here is the error:
Code:
./script: line 9: syntax error near unexpected token `else'
./script: line 9: `else'
Here is the second variant:
Code:
if /bin/grep -e $1 /etc/passwd > /dev/null
HOMEDIR="$( /bin/grep -e ^$1 /etc/passwd | cut -d: -f6 )"
CURSH="$( /bin/grep -e ^$1 /etc/passwd | cut -d: -f7 )"
echo "$CURSH"
echo "$HOMEDIR"
exit;
fi
And here is the error:
Code:
./script: line 8: syntax error near unexpected token `fi'
./script: line 8: `fi'
Here is the third variant:
Code:
#!/bin/bash
if /bin/grep -e $1 /etc/passwd > /dev/null
HOMEDIR="$( /bin/grep -e ^$1 /etc/passwd | cut -d: -f6 )"
CURSH="$( /bin/grep -e ^$1 /etc/passwd | cut -d: -f7 )"
echo "$CURSH"
echo "$HOMEDIR"
exit;
else
echo "No Such User Here."
exit;
exit;
And here is the error:
Code:
./script: line 9: syntax error near unexpected token `else'
./script: line 9: `else'
Not sure what's going on here. I'm usually pretty good with bash (with a few minor gaps), but this has me stumped. Really stumped. I thought the first variant would work without a hitch. Is there something I'm missing that I'll probably catch tomorrow or when its mentioned? Probably something right under my nose, I don't know. Maybe someone can spot a flaw right off.