[K12OSN] user account scripts

Robert Arkiletian robark at gmail.com
Tue Jan 9 18:58:11 UTC 2007


On 1/9/07, Robert Arkiletian <robark at gmail.com> wrote:
> On 1/9/07, Ray Garza <ray at mission.lib.tx.us> wrote:
> > Hi Robert,
> >
> > I tried your python script below on my home PC and it worked. But, when I try
> > it on my work PC it doesn't. I get an error message as follows:
> >
> > sys:1: DeprecationWarning: Non-ASCII character '\xc2' in file import_os on
> > line 7, but no encoding declared; see
> > http://www.python.org/peps/pep-0263.html for details
> >   File "import_os", line 7
> >      userinfo=i.split()
> >     ^
> > SyntaxError: invalid syntax
> >
> > I'm using Python version 2.4.4 at work and the box I really want it on is
> > using version 2.3.4.
>
> I don't think the version of python matters. Looks like you are using
> a password with the escape sequence
>
> \x
>
> which represents unicode (non standard ascii)

Sorry it's not unicode. It's a hexadecimal escape sequence. Same problem though.

> http://www.codecodex.com/wiki/index.php?title=Escape_sequences
>
> I am not sure how you would fix this. Other python people are welcome
> to help. :)
> My only suggestion would be try not to have the backslash char "\" in
> usernames or passwords.
>
> >
> > On the 2.3.4 box I also get the same error message.
> >
> > Ray
> >
> > On Thursday 04 January 2007 18:19, Robert Arkiletian wrote:
> > > On 1/4/07, Ray Garza <ray at mission.lib.tx.us> wrote:
> > > > Hello Script Gurus,
> > > >
> > > > Anyone know how to create user accounts from a text file using scripts?
> > > >
> > > > Example:
> > > >
> > > > user_accounts.txt
> > > > "username1","password"
> > > > "username2","password"
> > > > "username3","password"
> > > > "username4","password"
> > > >
> > > > convert that list into users on a local machine
> > >
> > > well here is one that works without the "," between the username and
> > > password and no quotes around the strings.
> > >
> > >
> > > #!/usr/bin/python
> > > import os
> > >
> > > f=file('/home/ray/user_accounts.txt','r')
> > > for i in f:
> > >     userinfo=i.split()
> > >     os.system("/usr/sbin/useradd -g users -n "+userinfo[0])
> > >     #check man page for useradd to customize as needed
> > >     os.system("echo " +userinfo[1]+" | /usr/bin/passwd "+
> > > userinfo[0]+" --stdin")
> > > f.close
> > >
> > > I haven't really tested it properly so use it at your own risk.
> > >
> > > > Better yet I need to convert a dbase file of usernames and passwords into
> > > > valid local user accounts. I can convert the dbase file to other formats
> > > > if that helps.
> > > >
> > > > Thanks
> > > >
> > > > Ray
> > > >
> > > > _______________________________________________
> > > > K12OSN mailing list
> > > > K12OSN at redhat.com
> > > > https://www.redhat.com/mailman/listinfo/k12osn
> > > > For more info see <http://www.k12os.org>
> >
> >
> > _______________________________________________
> > K12OSN mailing list
> > K12OSN at redhat.com
> > https://www.redhat.com/mailman/listinfo/k12osn
> > For more info see <http://www.k12os.org>
> >
>
>
> --
> Robert Arkiletian
> Eric Hamber Secondary, Vancouver, Canada
> Fl_TeacherTool http://www3.telus.net/public/robark/Fl_TeacherTool/
> C++ GUI tutorial http://www3.telus.net/public/robark/
>


-- 
Robert Arkiletian
Eric Hamber Secondary, Vancouver, Canada
Fl_TeacherTool http://www3.telus.net/public/robark/Fl_TeacherTool/
C++ GUI tutorial http://www3.telus.net/public/robark/




More information about the K12OSN mailing list