[K12OSN] More scripting help...

Brian Webport brian at portsmouth-college.ac.uk
Thu Sep 8 13:19:25 UTC 2005


Shawn Powers wrote:

> Ok, I'm sorry to use this list as my personal scripting helpline --  
> but it's the third day of school, and I'm in a real bind...  (DNS pun  
> not intended)
>
> Here's my script for changing passwords:
> #!/usr/bin/expect
> # script name mypasswd
> set username [lindex $argv 0]
> set password [lindex $argv 1]
> set name [lindex $argv 2]
> spawn passwd $username
> expect "password:"
> send "$password\r"
> expect "password:"
> send "$password\r"
> spawn chfn -f "$name" $username
> expect eof
>
> it works, as long as I put the "name" in quotes (due to the issue of  
> spaces)
>
> In my bulk script, however, I can't seem to get the variable assigned  
> correctly.  I don't know how to make it assign the whole name (both  
> first and last) with the space.  Here's my bulk script:
>
> #!/bin/bash
> # script name mybulkpasswd
> for lines in `cat $1`
> do
> username=`echo $lines | awk -F: '{print $1}'`;
> password=`echo $lines | awk -F: '{print $2}'`;
> name="`echo $lines | awk -F: '{print $3}'`";
> mypasswd $username $password "$name";
> done
>
> Here's an example bulk file:
>
> testuser:testpass:Test User
> test1:test1:Test Account 1
>
>
> Any more insight?
> Thanks, and I am sorry for all my questions,
> -Shawn
>
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>

Try webmin, this has a bulk import facilty

Brian




More information about the K12OSN mailing list