shell script help for users


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script help for users
# 8  
Old 11-15-2007
Hi - please see below ... so far could not make it working :-(
Thanks for the help.

###########################################
#!/bin/sh
# uid.sh

while read v2.txt test.ldif
do
case "$v2.txt" in
uid: )
echo "$test.ldif"
;;
* )
;;
esac
done < test.ldif

######################################


#!/bin/sh
# uid2.sh

test.ldif="$1"

while read v2.txt
do
if test "$v2.txt" = "$test.ldif"
then
exit 0
fi
done

exit 1;


#####################################

./uid.sh | uid2.sh next-uid

#####################################


#!/bin/sh
# uid3.sh

while read v2.txt
do
./uid.sh | ./uid2.sh "$v2.txt"
if test "$?" = "0"
then
echo user "$v2.txt" exists
else
echo user "$v2.txt" does not exist
fi
done <users

####################################
# 9  
Old 11-15-2007
Hm,

the construct

Code:
while read VAR1 VAR2 VAR3 .... VARN
do
    ..... $VAR1 etc ....
done <FILE

expects FILE to be the filename you want to read
and VAR1 VAR2 etc to be variable names to be used inside the do/done.

The idea of splitting these up into individual scripts is you can test them individually, so running the first script should just print a list of valid userids from the ldap dump.
# 10  
Old 11-15-2007
mmmm if i understood correctly, VAR1, VAR2 .. etc are uid's ....but there are so many of them in a txt file. Is there a way I can get the txt running against the ldif to check all uids ? Thanks much...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script for creating multiple users with password

for UserName in `cat users` ; do useradd -d /u02 -s /usr/libexec/openssh/sftp-server -G ftp-users $UserName ; PassWord=$( echo $( tr '' '' <<< ${UserName:0:1} )${UserName:1} ) ; echo "$PassWord@123" | passwd $UserName --stdin ; done can some one explain what the bold text do Please use... (5 Replies)
Discussion started by: James0806
5 Replies

2. BSD

Creating an array out of users: shell script

I want to create a shell script for a menu selection consisting of users defined on the machine. To an administrator having the privileges, the selection menu will look as follows: Select the user you want to define the variables for: 1) my-username-1 2) my-username-2 etc Then there would be a... (7 Replies)
Discussion started by: figaro
7 Replies

3. Solaris

Shell script to add users on solaris

Hi admins, I am trying to run a script to add users on solaris with password: I am using crypt for passwords: The part of my scripts is as below: if ; then echo "$username exists!" exit 1 else pass=$(perl -e 'print... (5 Replies)
Discussion started by: snchaudhari2
5 Replies

4. Shell Programming and Scripting

Help with shell script - creating users

echo -e "Enter in a username : \c" read username grep "^$username:" /etc/passwdWhat I'm trying to do is take in a username from my script and I need to be able to check if that username already exists. If it does the script should display a message saying that the user already exists and exit. ... (2 Replies)
Discussion started by: shadowcat
2 Replies

5. Shell Programming and Scripting

shell script for monitoring users activities

hi I need a shell script which runs perpetually in background and monitors different aspects of different users on different files and their usages for example say there r 3 users so i want when they log in i.e. their log in time and their file access, modify and change log of each file of a... (3 Replies)
Discussion started by: rrd1986
3 Replies

6. Shell Programming and Scripting

script check the users in SHELL every 1 minute ?

could you please find a solution for this: I need to write a shell script which checks after every minute whether a friend has logged in or not.The script should report whether that person has logged in along with the amount of time the person was late in logging in. I have no idea how to... (2 Replies)
Discussion started by: blunderblitz
2 Replies

7. Shell Programming and Scripting

shell script to find unowned users and groups

Hello, I am new to Unix and shell scripting. I am trying to find unowned files and groups on my servers. I know, i could use the below command to find it on individual server. #find / -nouser -o -nogroup -print But I was wondering, if someone could help with a shell script so that I can... (2 Replies)
Discussion started by: ut916
2 Replies

8. OS X (Apple)

interactive shell script to create users 10.4

Hello everyone, Not sure if this is the right place, but OS X isn't your standard Unix, so I figured here would be best. I am looking at creating a script that will be interactive that admins can run to create users. Now, 10.4 uses netinfo database and netinfo manager to handle it's users. ... (3 Replies)
Discussion started by: tlarkin
3 Replies

9. Shell Programming and Scripting

script check the users in SHELL ?

could you please find a solution for this script that checks if any of a list of users given on the command line is logged in. For each user the script should say whether this user is logged in or not. The script prints an error message if no parameter is given. And ask the user to enter a name... (3 Replies)
Discussion started by: anything
3 Replies

10. Shell Programming and Scripting

Bourne Shell script - log for users loggin on and off

Hello all, I'm new to shell scripting and want to make a script that I can write to log the users logging on and off the a unix system. I have had a good look over the past few days to crack it, I think I am getting close. I want a script that runs an infinite loop to check every 5 seconds... (14 Replies)
Discussion started by: noodlesoup
14 Replies
Login or Register to Ask a Question