[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Strange Segfault

Daniel Berger

7/13/2007 7:10:00 PM



On Jul 13, 12:03 pm, "Glen Holcomb" <damnbig...@gmail.com> wrote:
> I have an interesting problem. I have a script that I wish to use to check
> a database and then map drives based on who is logging on and the info in
> the database.
>
> When I run the script on any of the machines in the computer lab it
> segfaults. When I copy the exact same code that is in the script into an
> irb session and run it I don't have any trouble. I can run the script
> proper on my office workstation.
>
> Does anyone have any idea what could be causing this?
>
> I'm running ruby 1.8.6 on all the machines in question.
>
> Here is the script:
>
> require 'Win32API'
> require 'xmlrpc/client'
>
> class User
> def lookup
> user = "0" * 20
>
> getUserName = Win32API.new("advapi32", "GetUserName", 'P', "V")
>
> getUserName.call(user)
>
> return user
> end
>
> def account_created?(login)
> server = XMLRPC::Client.new2('http://localhost:3003/user/api')
>
> result = server.call('Check', login)
>
> if result == 0
> return false
> else
> return true
> end
> end
>
> def map_drives(login)
> system("net use x: /delete /y")
> system("net use l: /delete /y")
> system("net use x: //cad1/#{login}")
> system("net use l: //cad1/shared")
> end
> end
>
> user = User.new
>
> username = user.lookup
>
> if user.account_created?(username)
> user.map_drives(username)
> end

What version of Windows are you on? Is there a backtrace you could
show us? That would help us determine whether or not it's the system
calls or something else.

Regards,

Dan


2 Answers

Daniel Berger

7/13/2007 9:09:00 PM

0

On Jul 13, 2:39 pm, "Glen Holcomb" <damnbig...@gmail.com> wrote:

<snip>

> Okay for reasons I'm not sure of right now and don't have time to
> investigate changing the server.call to server.call2 fixed the problem.

<snip>

For some reason my last post never made it...

In short, your declaration of GetUserName is wrong - it takes 2
parameters, not 1, and you aren't checking for failure. As it stands
now it looks like "login" will always be an empty string.

Save yourself some time and use Admin.get_login from the sys-admin
package, which you can install via rubygems.

Regards,

Dan


Daniel Berger

7/16/2007 4:01:00 PM

0



On Jul 16, 8:04 am, "Glen Holcomb" <damnbig...@gmail.com> wrote:
> Daniel,
>
> sys-admin looks like it will do what I need however the link (http://tinyurl...) in the documentation on rubyforge is broken. MSDN
> just throws a 404 page.

That's because MS insists on moving its documentation every 6 months
in order to make it more Ajaxy and less functional. But I digress...

Try http://msdn2.microsoft.com/en-us/library/aa7... and look at
the "properties" section.

For future searchers if that link is dead just search msdn.com on
"IADsGroup" or "adsi + group".

Regards,

Dan