Sponsored Content
Top Forums Shell Programming and Scripting Logging in unix account taking password from a parameter file Post 302514691 by ygemici on Sunday 17th of April 2011 01:54:12 PM
Old 04-17-2011
I dont know exeactly what do you want but i try to make some simple script.

first of all you have to root permission.
if you change home directory other user then you need write permission in home directory else we get error like in below (permission error)
after you must run visudo and add pkbond to wheel group.
because of usermod is neccessary us and this is super command.

Code:
# usermod -G wheel pkbond

Code:
# cat /usr/etc/.paramlist
ab01 passab01 pkbond
ab02 passab02 ??????

Code:
[pkbond@rhnserver ~]$ ./justdoit
Before  running script
/home/oper/pkbond
uid=514(pkbond) gid=514(oper)
mkdir: cannot create directory `/home/oper/ab01': Permission denied
Only root can do that.
ab01 processes are OK!!
 
After running script
/home/oper/ab01
uid=514(ab01) gid=514(oper)
 
ab02 is not logged or is not parameter list!!

Code:
[pkbond@rhnserver ~]$ cat justdoit
#!/bin/bash
## justdoit
parameterfile=/usr/etc/.paramlist
#chown pkbond.pkbond $parameterfile
#chmod go-rwx $parameterfile
shopt -s expand_aliases
alias usermod='sudo '/usr/sbin/usermod' '
HOME=/home/oper
USER=$(id -un)
change_users () {
 while read -r newuser passwd loggeduser
  do
   if [[ $(who -u | grep $USER ) ]] && [[ $(echo $loggeduser | grep $USER) ]]  ; then
    echo -e "Before  running script \n$(finger $USER |awk '/Direct/ { print $2 }') \n$(id $USER |sed 's/\([^ ]* [^ ]*\).*/\1/')\n"
    mkdir -p $HOME/$newuser ; usermod -d $HOME/$newuser $USER
    usermod -l $newuser $USER ; echo "$passwd" | passwd --stdin $newuser ; echo "$newuser processes are OK!!" ; echo
    echo -e "After running script \n$(finger $newuser |awk '/Direct/ { print $2 }') \n$(id $newuser |sed 's/\([^ ]* [^ ]*\).*/\1/')"
   else
    echo -e "\n$newuser is not logged or is not parameter list!!"
   fi
  done < $parameterfile
}
change_users ""


regards
ygemici
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

not taking password for su on mac os x

Hello, I can't install matlab on my new mac os X because I am not logged in as a superuser. I type su root and it doesn't take my password. It just says sorry. Is there a way to just reset it? Thanks, Z (3 Replies)
Discussion started by: zitz
3 Replies

2. UNIX for Dummies Questions & Answers

Change Account to not lock account if password expires

I have access to 15+ UNIX boxes at work, and I do not consistently log onto all of them over time. When I do try to access one I havent been on in awhile, my account is locked as the password has expired. I need to request to the UNIX SA's that the password expiration is 90 days and that if it... (1 Reply)
Discussion started by: stringzz
1 Replies

3. UNIX for Advanced & Expert Users

How to update my account password on 100 unix server ?

Hi We have over 100 unix servers. They include linux,solaris,aix,hp and sgi. I use telnet for some and ssh for rest. Note: none of this server has expect which i can use to update.So i am looking for expert who can help me with their script or guide me write KSH script to automate this. Thank... (6 Replies)
Discussion started by: humaurtum
6 Replies

4. Shell Programming and Scripting

Execute via crontab taking username/password from file

Dear All Here is the details what i want to achieve from shell scripts I have a sever where 5 databases are created. which i having diffrent SID's. Now i want to execute some SQL queries on each one of the databases. (SQL Query is same).That i want to acheive via crontab Now each one of the... (2 Replies)
Discussion started by: jhon
2 Replies

5. UNIX for Dummies Questions & Answers

User account logging

Hi - I want to log commands typed by oraapps user with time into some log file on runtime. HISTTIMEFORMAT="%d/%m/%y %T " works but any one with oraapps user can delete the history. OS : RHEl 5.6 Any help is appreciated. (5 Replies)
Discussion started by: oraclermanpt
5 Replies

6. UNIX for Dummies Questions & Answers

SQLPLUS Password Parameter file being used when logging in

Good day to everyone. This is my first time posting and just barely above basic Unix training. I think i have search thoroughly to ensure my question hasn't already been posted. But on the off chance the answer has been posted, please be nice as I am not 100% sure I know what I am looking for. I... (1 Reply)
Discussion started by: Mrjester
1 Replies

7. Shell Programming and Scripting

Taking mirror copy of the application id and password into the new UNIX machine

I am working in Datastage Migration project. The applications has to be moved from legacy machines to the new machines. all the applications will be having their own application id and password (non expiry) created in the unix (5.3). Now the scripts and the datastage applications has to be moved... (1 Reply)
Discussion started by: kmanivan82
1 Replies

8. Shell Programming and Scripting

Tar file with logging and directory via parameter

Hi all, I am fairly new to shell scripting and I am trying the following: My shell script creates a tar file with files with the ending ~. The directory - where the files and sub directories are located - comes as a parameter when I call the script. Files that are archived will be written in... (1 Reply)
Discussion started by: neg42
1 Replies

9. Shell Programming and Scripting

Get the two parameter from text file in UNIX.

Hi there, In my attachment there is 'Category/Subcategory' & 'Setting'. var=$(awk '/^Logon\/Logoff/ {P=0} P {print $0} FNR==1{printf("From file %s:\n", FILENAME)} /^System/ {P=1}' $file |grep -ia "IPsec Driver" );echo $var As of now I am able to From File: Policies.txt IPsec... (2 Replies)
Discussion started by: alvinoo
2 Replies

10. Shell Programming and Scripting

Logging in to 100 server to test my account

I have been logging to 100 server everyday to test if I can login to the server. I created a script to ssh-copy-id to every host so next time it will be password less. Now it keeps prompting me Are you sure you want to continue connecting (yes/no)? yes This is normal for first time login.... (2 Replies)
Discussion started by: invinzin21
2 Replies
NEWUSER(8)						      System Manager's Manual							NEWUSER(8)

NAME
newuser - adding a new user SYNOPSIS
rc /sys/lib/newuser DESCRIPTION
To establish a new user on Plan 9, add the user's name to /adm/users by running the newuser command on the console of the file server (see users(6) and fs(8)). Next, give the user a password using the changeuser command on the console of the authentication server (see auth(8)). At this point, the user can bootstrap a terminal using the new name and password. The terminal will only get as far as running rc, however, as no profile exists for the user. The rc(1) script /sys/lib/newuser sets up a sensible environment for a new user of Plan 9. Once the terminal is running rc, type rc /sys/lib/newuser to build the necessary directories in /usr/$user and create a reasonable initial profile in /usr/$user/lib/profile. The script then runs the profile which, as its last step, brings up 81/2(1). At this point the user's environment is established and running. (There is no need to reboot.) It may be prudent at this point to run passwd(1) to change the password, depending on how the initial password was cho- sen. The profile built by /sys/lib/newuser looks like this: bind -a $home/bin/rc /bin bind -a $home/bin/$cputype /bin font = /lib/font/bit/pelm/euro.9.font switch($service){ case terminal prompt=('term% ' ' ') fn term%{ $* } exec 81/2 case cpu bind -b /mnt/term/mnt/81/2 /dev prompt=('cpu% ' ' ') echo -n $sysname > /dev/label fn cpu%{ $* } news case con prompt=('cpu% ' ' ') news } Sites may make changes to /sys/lib/newuser that reflect the properties of the local environment. Use the -c option of mail(1) to create a mailbox. SEE ALSO
passwd(1), 81/2(1), namespace(4), users(6), auth(8), fs(8) NEWUSER(8)
All times are GMT -4. The time now is 02:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy