With a typo fixed ==== Traditionally people use sed, not vi from scripts. And I'm not sed user. :< Fortunately, I don't think you need it anyway. Without testing it at all, I think you need something along the lines of: === #!/bin/sh while read LINE ; do UID=`echo $LINE | cut -d: -f 1` NAME=`echo $LINE | cut -d: -f 2` if [ $UID != UID ]; then useradd $UID $NAME # I don't know the right arguments offhand. fi done < passwordfile === If you save the to a file xyz, thing test it by running "sh -x xyz", you will get debug output. Hope that gives you enough to get started. Greg
hi:
Can someone who knows shell scripting help me with this:
I want to write a simple script that will add logins to my password file using these commands:
o vi o while o read o echo o useradd ??etc?..
This input file called "passwordfile" has these users to be added to my password file:
<Snip>
UID:Name jms:John Smith poi:Peter Inkspot lkj:Linda Jones hgf:Harry Fargo nbv:Nancy Vaughn sdf:Sam Fettucini lkj:Larry Johnson
<Snip>
thanks
__________________________________________________ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Greg Freemyer Internet Engineer Deployment and Integration Specialist Compaq ASE - Tru64 v4, v5 Compaq Master ASE - SAN Architect The Norcross Group www.NorcrossGroup.com
Maybe even simpler: #!/bin/sh IFS=":$IFS" # add a colon to the whitespace characters, while read UID NAME ; do if [ $UID != UID ]; then useradd $UID $NAME # I don't know the right arguments offhand. fi done < passwordfile On 27 Aug 2002 at 17:14, Greg Freemyer wrote:
With a typo fixed
====
Traditionally people use sed, not vi from scripts.
And I'm not sed user. :<
Fortunately, I don't think you need it anyway.
Without testing it at all, I think you need something along the lines of:
=== #!/bin/sh
while read LINE ; do UID=`echo $LINE | cut -d: -f 1` NAME=`echo $LINE | cut -d: -f 2` if [ $UID != UID ]; then useradd $UID $NAME # I don't know the right arguments offhand. fi done < passwordfile ===
If you save the to a file xyz, thing test it by running "sh -x xyz", you will get debug output.
Hope that gives you enough to get started.
Greg
hi:
Can someone who knows shell scripting help me with this:
I want to write a simple script that will add logins to my password file using these commands:
o vi o while o read o echo o useradd ??etc?..
This input file called "passwordfile" has these users to be added to my password file:
<Snip>
UID:Name jms:John Smith poi:Peter Inkspot lkj:Linda Jones hgf:Harry Fargo nbv:Nancy Vaughn sdf:Sam Fettucini lkj:Larry Johnson
<Snip>
thanks
__________________________________________________ Do You Yahoo!? Yahoo! Finance - Get real-time stock quotes http://finance.yahoo.com
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
Greg Freemyer Internet Engineer Deployment and Integration Specialist Compaq ASE - Tru64 v4, v5 Compaq Master ASE - SAN Architect The Norcross Group www.NorcrossGroup.com
-- Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com
-- Jerry Feldman Enterprise Systems Group Hewlett-Packard Company 200 Forest Street MRO1-3/F1 Marlboro, Ma. 01752 508-467-4315 http://www.testdrive.compaq.com/linux/
participants (2)
-
Greg Freemyer
-
Jerry Feldman