# User Account Setup - Multiple OS's

**URL:** <https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119>\
**Category:** Ruby\
**Created:** [May 20, 2006, 2:38pm UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119 "2006-05-20T14:38:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 20, 2006, 2:38pm UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/1 "2006-05-20T14:38:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 22, 2006, 3:23am UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/2 "2006-05-22T03:23:33Z")

</div>

On 5/20/06, Paul D. Kraus [removed\_email\_address@domain.invalid](mailto: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

---

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 23, 2006, 5:07am UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/3 "2006-05-23T05:07:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 23, 2006, 1:09pm UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/4 "2006-05-23T13:09:47Z")

</div>

> 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?

---

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 23, 2006, 1:22pm UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/5 "2006-05-23T13:22:00Z")

</div>

Umm, maybe [http://raa.ruby-lang.org/](http://raa.ruby-lang.org/)

j`ey http://code.eachmapinject.com/j`ey.rb[http://code.eachmapinject.com/j`ey.rb](http://code.eachmapinject.com/j%60ey.rb)

---

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 22, 2006, 4:03am UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/6 "2006-05-22T04:03:10Z")

</div>

On 5/20/06, Paul D. Kraus [removed\_email\_address@domain.invalid](mailto: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/](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](http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html))  
or cmdparse ([http://cmdparse.rubyforge.org/](http://cmdparse.rubyforge.org/)) or commandline (gem  
install commandline, [http://rubyforge.org/projects/optionparser/](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

---

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 23, 2006, 2:37pm UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/7 "2006-05-23T14:37:15Z")

</div>

On 5/23/06, Joey [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Umm, maybe [http://raa.ruby-lang.org/](http://raa.ruby-lang.org/)
> 
> j`ey http://code.eachmapinject.com/j`ey.rb\<  
> [http://code.eachmapinject.com/j`ey.rb](http://code.eachmapinject.com/j%60ey.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

---

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 23, 2006, 3:04pm UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/8 "2006-05-23T15:04:41Z")

</div>

Paul D. Kraus wrote:

> On 5/23/06, Joey [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Umm, maybe [http://raa.ruby-lang.org/](http://raa.ruby-lang.org/)
> > 
> > j`ey http://code.eachmapinject.com/j`ey.rb\<  
> > [http://code.eachmapinject.com/j`ey.rb](http://code.eachmapinject.com/j%60ey.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.  
([https://pragprog.com/titles/ruby/programming-ruby-2nd-edition/](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/](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/](http://docs.rubygems.org/)

---

<div class="post-metadata">

**Author:** ![Paul\_DSKraus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ed655f/32.png) [@Paul\_DSKraus](https://www.ruby-forum.com/u/Paul_DSKraus)\
**Post date:** [May 23, 2006, 3:09pm UTC](https://www.ruby-forum.com/t/user-account-setup-multiple-oss/61119/9 "2006-05-23T15:09:18Z")

</div>

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

> On 5/23/06, Joey [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Umm, maybe [http://raa.ruby-lang.org/](http://raa.ruby-lang.org/)
> > 
> > j`ey http://code.eachmapinject.com/j`ey.rb\<  
> > [http://code.eachmapinject.com/j`ey.rb](http://code.eachmapinject.com/j%60ey.rb)\>

I would add [http://www.rubyforge.net](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](http://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.
