#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2016
    Posts
    3
    Rep Power
    0

    Question Adding multiple users and setting vnc passwords?


    I can add users using the following commands without specifying a group
    # useradd USER1
    # passwd USER1
    password: ******
    Retype password:
    password: ******

    but if I use the following script with a text file (user_list.txt) containing list of user, i.e. one user per line and user name

    and password separated by a space, will that work? Am I missing something in the script?

    =======================
    #!/bin/bash
    NEW_USERS="/tmp/scripts/user_list.txt"
    HOME_BASE="/home/"

    cat ${NEW_USERS} | \
    while read USER PASSWORD
    do
    useradd -p ${PASSWORD} -m -d ${HOME_BASE}${USER} ${USER}
    done
    =======================

    user_list.txt content:
    =======================
    USER1 USER1_PASSWORD
    USER2 USER2_PASSWORD
    USER3 USER3_PASSWORD
    ...
    USER9 USER9_PASSWORD
    =======================

    For the same users I have to set the vnc password for each user manually using the following commands
    # su - USER1
    $ vncpasswd
    password: ******
    Retype password: ******
    $ exit

    How can I write a script to read the same text file and set vnc passwords?
    BTW I am using Red Hat Linux 5.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2016
    Posts
    3
    Rep Power
    0
    I managed to get the user add script work, but how to write the following commands in a script for setting vnc password for multiple users? I need to read a text file (user_list.txt) containing list of user, i.e. one user per line and user name and password separated by a space.

    # su - USER1
    $ vncpasswd
    password: ******
    Retype password: ******
    $ exit

    user_list.txt content:
    =======================
    USER1 USER1_PASSWORD
    USER2 USER2_PASSWORD
    USER3 USER3_PASSWORD
    ...
    USER9 USER9_PASSWORD
    =======================

IMN logo majestic logo threadwatch logo seochat tools logo