User Account Setup - Multiple OS's


#1

I am learning ruby and have a background in perl.
As my first project and to help me get my head around ruby I want to
create
a useradmin script that will let me do the following.

  • Remotely create a domain user on a windows 2000 server
  • Remotely create a user on a sco openserver box
  • Remotely create a directory on Linux
  • remotely create a user on Linux
  • remotely append to the smb.conf on Linux
  • Login into or webmail admin page and create a new email user
  • Remotely add mac address to a squid access list
  • remotely restart squid

From input(gui at a later time, from command line switches now):
user’s full name
user’s password
username
switch for add and a switch for remove

New hire starts at company type one command from their new workstation
and
have it set them up with all of their accounts.

Obviously having some kind of decent directory service in place and
single
sign on would help elevate this problem but on my task list it seems to
never get to the top. PLUS I think this will be a great exercise in
learning
a lot about ruby.

So what I would like from you is not to tell me how but to point on some
of
the modules(if that’s what they are called in ruby) that will help me
get
this task done. Help me get past the hurdle of what ruby tools I should
use
so that I can dig into the documents for those modules and code it on my
own.

New to OO thinking so I am going to be fighting a desire to write this
procedurally but the idea is to have some kind of user object that would
handle all of this.

Maybe a basic user object and then a sub class of user for accounts.
shurg
I have no idea like I said I am just jumping into the deep end here.

Your thoughts are always appreciated.

Paul Kraus

OH yeah the script (at least how i see it) would be sitting out on a
samba
share on a Linux machine but being run on the actual workstation that
the
new hire will be using.


#2

On 5/20/06, Paul D. Kraus removed_email_address@domain.invalid wrote:

I am learning ruby and have a background in perl.
As my first project and to help me get my head around ruby I want to
create
a useradmin script that will let me do the following.

From the lack of responses I am getting the feeling that maybe ruby
isn’t
the best tool for this. If this is the case please point me to the right
tools.

Paul


#3

On Mon, May 22, 2006 at 10:23:08AM +0900, Paul D. Kraus wrote:

Paul

Ruby is very well suited for this, if that is the only answer to you
care for.

I guess lack of response has more to do with people beeing unwilling
to do your homework, though. Try breaking it up and ask for specific
problems instead.

Jürgen


#4

I guess lack of response has more to do with people beeing unwilling
to do your homework, though. Try breaking it up and ask for specific
problems instead.

I don’t think i was asking for “my homework” to get done. In fact was
asking for just the oppsite. Just for suggested modules that other
people
had done.

shrug

at any rate lets try this approach. Does ruby have something comparable
to
CPAN for seaching/installing modules?


#5

Umm, maybe http://raa.ruby-lang.org/

jey http://code.eachmapinject.com/jey.rbhttp://code.eachmapinject.com/j`ey.rb


#6

On 5/20/06, Paul D. Kraus removed_email_address@domain.invalid wrote:

I am learning ruby and have a background in perl.
As my first project and to help me get my head around ruby I want to create
a useradmin script that will let me do the following.

  • Remotely create a domain user on a windows 2000 server

See Win32API or other windows related libraries.

  • Remotely create a user on a sco openserver box
  • Remotely create a directory on Linux
  • remotely create a user on Linux
  • remotely append to the smb.conf on Linux

All the above can probably be done with Net::SSH:
http://net-ssh.rubyforge.org/

  • Login into or webmail admin page and create a new email user

Could be done with WWW:Mechanize (gem install mechanize)

  • Remotely add mac address to a squid access list
  • remotely restart squid

Probably Net::SSH again.

From input(gui at a later time, from command line switches now):
user’s full name
user’s password
username
switch for add and a switch for remove

See optparse
(http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html)
or cmdparse (http://cmdparse.rubyforge.org/) or commandline (gem
install commandline, http://rubyforge.org/projects/optionparser/)

New to OO thinking so I am going to be fighting a desire to write this
procedurally but the idea is to have some kind of user object that would
handle all of this.

I would suggest writing it procedurally if that is what you are
comfortable with, and then objectifying it later. I was born and
raised on OO, but with Ruby I almost always start with just coding
something quick and then making objects. That is one of the benefits
of Ruby: rapid prototyping.

OH yeah the script (at least how i see it) would be sitting out on a samba
share on a Linux machine but being run on the actual workstation that the
new hire will be using.

This should not be a problem as long as the script looks like a file to
Ruby.

Ryan


#7

On 5/23/06, Joey removed_email_address@domain.invalid wrote:

Umm, maybe http://raa.ruby-lang.org/

jey http://code.eachmapinject.com/jey.rb<
http://code.eachmapinject.com/j`ey.rb>

Exactly what I was looking for thanks. Any good newbie faq’s? Not really
on
the programming side of things but more on the supplemental tools such
as
the one you just gave me or good places to find online docs.

Oh and the biggest one… What the heck is GEM.

Why do scripts have both require and import statements?

This way I quit hitting the list with things that have probably been
covered
to death.

TIA,
Paul


#8

Paul D. Kraus wrote:

On 5/23/06, Joey removed_email_address@domain.invalid wrote:

Umm, maybe http://raa.ruby-lang.org/

jey http://code.eachmapinject.com/jey.rb<
http://code.eachmapinject.com/j`ey.rb>

Exactly what I was looking for thanks. Any good newbie faq’s? Not really
on
the programming side of things but more on the supplemental tools such
as
the one you just gave me or good places to find online docs.

Oh and the biggest one… What the heck is GEM.

Why do scripts have both require and import statements?

This way I quit hitting the list with things that have probably been
covered
to death.

TIA,
Paul

The standard reference for Ruby is the “Pickaxe” book, i.e. Programming
Ruby, 2nd Ed.
(http://www.pragmaticprogrammer.com/titles/ruby/index.html). This book
has answers to all your questions.

The 1st edition is dated but still quite useful and is available online
here: http://www.rubycentral.com/book/. This one explains the difference
between require and include.

You can read about “gems” (RubyGems) here: http://docs.rubygems.org/


#9

Le 23 mai 06, à 08:36, Paul D. Kraus a écrit :

On 5/23/06, Joey removed_email_address@domain.invalid wrote:

Umm, maybe http://raa.ruby-lang.org/

jey http://code.eachmapinject.com/jey.rb<
http://code.eachmapinject.com/j`ey.rb>

I would add http://www.rubyforge.net

Exactly what I was looking for thanks. Any good newbie faq’s? Not
really on
the programming side of things but more on the supplemental tools such
as
the one you just gave me or good places to find online docs.

Oh and the biggest one… What the heck is GEM.

Ruby package management. Many libraries/program are distributed with
gem. Look for RubyGems on rubyforge.

Why do scripts have both require and import statements?

‘require’ loads a file in your interpreter. ‘import’, don’t know what
that is. Are you talking about ‘include’?

You may want to look at www.ruby-doc.org. In particular the Pickaxe
(“Programming Ruby”) and the standard library documentation. And if it
was installed properly on your system, ‘ri’ is very handy:

[gus@hibernatus ~]$ ri require
--------------------------------------------------------- Kernel#require
require(string) => true or false

  Ruby tries to load the library named _string_, returning +true+ if
  successful. If the filename does not resolve to an absolute path,
  it will be searched for in the directories listed in +$:+. If the
  file has the extension ``.rb'', it is loaded as a source file; if
  the extension is ``.so'', ``.o'', or ``.dll'', or whatever the
  default shared library extension is on the current platform, Ruby
  loads the shared library as a Ruby extension. Otherwise, Ruby 

tries
adding .rb'',.so’’, and so on to the name. The name of the
loaded feature is added to the array in +$"+. A feature will not
be
loaded if it’s name already appears in +$"+. However, the file
name
is not converted to an absolute path, so that ``+require
‘a’;require ‘./a’+’’ will load +a.rb+ twice.

     require "my-library.rb"
     require "db-driver"

‘fxri’ on rubyforge is good also.

HTH,
Guillaume.