[5010] in RedHat Linux List
Re: shell scripting questions
daemon@ATHENA.MIT.EDU (Allen Francom)
Mon Nov 18 14:59:29 1996
Date: Tue, 19 Nov 1996 03:04:24 -0800 (PST)
From: Allen Francom <afrancom@numedics.transport.com>
To: tom mills <tmills@dimensional.com>
cc: redhat-list@redhat.com
In-Reply-To: <328EE567.77F8@dimensional.com>
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com
I don't like writing bash scripts, but I do perl, and it would work great
in just a few lines.
For your purposes modifying adduser, you might consider piping the output
of something straight into the adduser (modified version) script.
For a cheap crude (please don't do this) example,
cat myusers.txt | adduser
But this is the basic idea.
You would, of course, have to modify adduser to check for and report errors
if you did something like this, and you would have to format myusers.txt
to match what the keyboard input would be.
......
In perl you could open a file with one line, then start a loop that
reads a line into a variable, another command that splits the inputted
line into multiple variables, and another line to call adduser (or
duplicate adduser in Perl if it isn't already perl)
Just a few lines this way.
Also there is a language called EXPECT, based on TCL, and the basic idea
of it is to "Expect" something, and then "Send" something back to
whatever. It is an excellent scripting language that you can use to
control other programs or scripts as if it were a user sitting at a console.
Whatever.
I'd hate to give you an exact program when you'll have so much fun and
learn so much if you do it yourself...
How about I accept an occasional email for pointers if you get stuck ?
( I recently went through this same exact thing... )
THX
-AEF
On Sun, 17 Nov 1996, tom mills wrote:
> Sorry, not a 'redhat' specific question,
>
> But it is my OS of choice! i486dx4-100 running Colgate, all upgrades in
> place without a hitch.
>
> I'm trying to modify the /usr/sbin/adduser script to input a delimited
> file of user info, in one clean shot... But I really don't know much
> about scripting.
>
> Basically I have assigned "" to the $NOHOME variable, cause it doesn't
> do anything in the default script, and am using a command line arg as
> $PASS to hand the password to autopasswd so i don't have to! So what I
> have is a command line like: adduser bsmith @nudRUsr!
>
> I keep a database of the initial account stuff in.... MSAccess, only
> cause my boss makes me, but I thought why enter this stuff twice? I can
> put it in there and export myself a delimited file that contains:
> login:password:home:realname and be done with it if I could just figure
> out how to tell a shell script how to read lines out of a file and parse
> them in. Is this what that "readline" thing is?
>
> The parsing I'm getting from the awk man pages, but I could really use
> some examples from some of you regarding a script reading a disk file,
> if anyone does anything like this. I'm also trying to figure out a
> script or actual code that would match ss#'s in a student database file
> and allow users to add themselves.
>
> A little guidance please oh great guru's!
> thx
> --------------------------------------------------------------------
> Tom Mills System Administrator
> tmills@dimensional.com ccd.cccoes.edu
> Community College of Denver
> --------------------------------------------------------------------
>
>
> --
> PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
> ________________________________________________________________________
> http://www.redhat.com/RedHat-FAQ http://www.redhat.com/RedHat-Errata
> http://www.redhat.com/RedHat-Tips http://www.redhat.com/mailing-lists
> ------------------------------------------------------------------------
> To unsubscribe: mail -s unsubscribe redhat-list-request@redhat.com < /dev/null
>
--
PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
________________________________________________________________________
http://www.redhat.com/RedHat-FAQ http://www.redhat.com/RedHat-Errata
http://www.redhat.com/RedHat-Tips http://www.redhat.com/mailing-lists
------------------------------------------------------------------------
To unsubscribe: mail -s unsubscribe redhat-list-request@redhat.com < /dev/null