Network user on Linux

I am able to get the network user in windows though ENV['username'] but
this is not wokring on linux,
Is there any library we can use in both environments to get the network
user login?

···

--
Posted via http://www.ruby-forum.com/.

user = ENV['USER'] || ENV['USERNAME']

or maybe

require 'etc'
user = Etc.getlogin

Kind regards

robert

···

On Mon, Sep 12, 2011 at 12:52 PM, Mario Ruiz <tcblues@gmail.com> wrote:

I am able to get the network user in windows though ENV['username'] but
this is not wokring on linux,
Is there any library we can use in both environments to get the network
user login?

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

thanks a lot!!! it is working!!

Another thing related to this is, I need to get access to a file that is
on network drive and the problem is I can access it on windows like
//fileserver....
but in linyx is by using smb://fileserver so I need to identify which
system I'm using or if there is any way to do the same in both
systems...

Robert Klemme wrote in post #1021423:

···

On Mon, Sep 12, 2011 at 12:52 PM, Mario Ruiz <tcblues@gmail.com> wrote:

I am able to get the network user in windows though ENV['username'] but
this is not wokring on linux,

--
Posted via http://www.ruby-forum.com/\.

You could configure the URL and do this before file open on Windows:

path_to_open = windows? : file_name.sub /^smb:/, '' : file_name

Kind regards

robert

···

On Mon, Sep 12, 2011 at 1:24 PM, Mario Ruiz <tcblues@gmail.com> wrote:

thanks a lot!!! it is working!!

Another thing related to this is, I need to get access to a file that is
on network drive and the problem is I can access it on windows like
//fileserver....
but in linyx is by using smb://fileserver so I need to identify which
system I'm using or if there is any way to do the same in both
systems...

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/