- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl unitialized variable
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 10:08 AM
02-27-2002 10:08 AM
#!/opt/perl5/bin/perl -w
#
$userid = getlogin;
print $userid;
HOWEVER, the exact same script works on OTHER servers, with the same version of Perl installed (ver. 5.6.1).
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 10:39 AM
02-27-2002 10:39 AM
Re: Perl unitialized variable
Try a perl -V on both systems and compare the version.
I was able to reproduce this using my perl5 install (which is perl 5.03) to run your test program. Perl 5.03 worked fine. When I switched to /usr/contrib/bin/perl (version 4.something) I got the exact message you did.
It's possible that the getlogin wasn't implemented in 4.0 (I couldn't find a man page to validate this).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 10:54 AM
02-27-2002 10:54 AM
Re: Perl unitialized variable
$ ls -al perl*
-rw-r--r-- 1 nsandhar cmsi 1723 Feb 27 10:50 perl.V.out
-rw-r--r-- 1 nsandhar cmsi 1723 Feb 27 10:50 perl.V.out.atlas
$ diff perl.V.out perl.V.out.atlas
$
The output file is exactly the same. It also shows the version as 5.6.1:
Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 11:03 AM
02-27-2002 11:03 AM
Re: Perl unitialized variable
live free or die
harry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 11:08 AM
02-27-2002 11:08 AM
SolutionYou are not quite playing by the rules. First of all, getlogin requires that stdin be associated with a terminal device. Secondly, getlogin returns the current login name from /etc/utmp, it returns a null value if that fails and you should then use the getpwuid function.
This should work:
$userid = getlogin || getpwuid($<) || "Unknown";
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 12:13 PM
02-27-2002 12:13 PM
Re: Perl unitialized variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 02:04 PM
02-27-2002 02:04 PM
Re: Perl unitialized variable
Additionally, I've found that I cannot execute the passwd command - the response is "Usage: passwd [ -F file ] [ name ]".
The perl code mentioned in the original query above works properly if executed from a Telnet window, but fails if executed from an hpterm Xwindow created via a Rexec in Hummingbird eXceed product.
Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2002 02:15 PM
02-27-2002 02:15 PM
Re: Perl unitialized variable
As to your ExCeed problem, I don't know but I avoid PC based X-emulators like the plague. I find that they work 'almost perfectly' and that is the worst kind of problem to fight. I suspect that passwd is failing because it can't set echo to off.
Food for thought, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2002 01:55 AM
02-28-2002 01:55 AM
Re: Perl unitialized variable
Nishan could have found this if he only would have RTFM or in Perl-speach the POD
Nishan, at the shell prompt simply issue the following:
perldoc -f getlogin
perldoc -f getpwuid
perldoc perlvar
Clay has given a thorough explanation.
Maybe just to add,
$> is Perl's eff. UID, $< real UID, $) eff. GID, $( real GID (consult POD above)
getpwuid $<
returns a list of entries in /etc/passwd for the passed UID.
In scalar context however, as in the POD's or Clay's example, it only returns the first field of the matching entry in /etc/passwd.
This could also be accomplished by taking a slice
(getpwuid $<)[0]