in reply to Re: getlogin works on debian but not ubuntu?
in thread getlogin works on debian but not ubuntu?

Interesting. When I run your code on ubuntu, I get this:
perl -e 'print getlogin || getpwuid($<)' bcrowellx10001000Ben Crowell,,,/home/bcrowell/bin/bash
I guess getlogin fails, and that puts getpwuid's array output in scalar context or something? Dunno why it works differently on two versions of ubuntu.

Replies are listed 'Best First'.
Re^3: getlogin works on debian but not ubuntu?
by LanX (Saint) on Jan 07, 2013 at 01:46 UTC
    well getlogin worked for me, so getpwuid was never executed, just putting scalar in front seems to solve the issue for both of us (I wasn't thinking about print's list context)

    perl -e 'print scalar getpwuid($<) ' lanx

    Cheers Rolf

      Yeah, that works. I wonder if I should file a bug report on this...I'm not convinced I understand what's going on well enough to file a useful one. I assume per's getlogin() is just a wrapper for the C function, so maybe this is a bug in the C libraries in ubuntu precise?
        Works for me even on Ubuntu PP:
        mb@dennis ~ $ perl -E'say getlogin' mb mb@dennis ~ $ cat gl.c #include <unistd.h> #include <stdio.h> int main(void) { puts(getlogin()); return 0; } mb@dennis ~ $ gcc gl.c mb@dennis ~ $ ./a.out mb