?
Solved

help with shell scrip for Aix adding users

Posted on 2010-01-07
2
Medium Priority
?
1,035 Views
Last Modified: 2013-12-21
#!/usr/bin/ksh -x

umask 0077

PATH=/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin

ID=111

GROUP=ddd

USER=user1

PASSWORD=passw0rd

GECOS="some name"

HOME=/home/user1

#Check to see if the user exists
if grep -q $USER /etc/passwd
then
  echo "Account exists already."
  chuser pgrp=ddd  $USER
  echo "Setting up your ssh keys for paswordless logins.."
  HOME=/home/$USER
  echo "Home directory is $HOME"
  umask 027
     if [ "$HOME" = "" ]
     then
       echo "HOME variable is not set correctly.  Exiting..."
       exit 5
     else
    mkdir ${HOME}
   chown -R $USER ${HOME}
fi
echo "Completed."
  exit 103

else
  echo "Creating user...."

mkuser id=${ID} pgrp=${GROUP} gecos="${GECOS}" groups=${GROUP} shell=/usr/bin/ksh ${USER} home=/home/${USER}

        echo "${USER}:${PASSWORD}" | chpasswd -c  -e
fi
echo "Completed."t 0


 I am getting an error when i run the script ...
3004-694 Error adding "home=/home/user1" : Value is invalid.

Thanks for your help .....
0
Comment
Question by:kaka123
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 total points
ID: 26203931
username ( ${USER} must be the last parameter

mkuser id=${ID} pgrp=${GROUP} gecos="${GECOS}" groups=${GROUP} shell=/usr/bin/ksh home=/home/${USER} ${USER}
0
 

Author Comment

by:kaka123
ID: 26204143
That was it ...You are correct ...Thanks for your help ...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

807 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