Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

if then else fi - error with folder exists

Posted on 2009-05-05
2
Medium Priority
?
219 Views
Last Modified: 2013-12-26
My script causes error:

without argument
# ./scriptname
#: line 9: syntax error near unexpected token `else'
#: line 9: `else'

with argument i get the same


anyone know what im doing wrong?
# $1 = wanted username
if [ "$1" ] then
        if [ -d /home/$1 ]; then
                echo "User exists..."
        else
                echo "do stuff"
        fi
else
        echo "Missing"
fi

Open in new window

0
Comment
Question by:us-pata
2 Comments
 
LVL 10

Accepted Solution

by:
mahome earned 500 total points
ID: 24302537
you missed the semikolon (;) in row 2
0
 
LVL 1

Author Closing Comment

by:us-pata
ID: 31577924
thx. so obvous, but im now to this so thx :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
This article will show you step-by-step instructions to build your own NTP CentOS server.  The network diagram shows the best practice to setup the NTP server farm for redundancy.  This article also serves as your NTP server documentation.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month9 days, 12 hours left to enroll

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question