Operating System - HP-UX
1833901 Members
1842 Online
110063 Solutions
New Discussion

Checking for $LOGNAME on another server

 
Leslie Chaim
Regular Advisor

Checking for $LOGNAME on another server

Hi,

Is there an easy way to identify if a given $LOGNAME or $(whoami)or $(logname), whatever exists on another server?

I am developing a distributed application in Java and for testing purposes, I need this functionality. The production version is always as ops. However, for testing, I want that anyone installing the test app should have an account on every box/server where the app is running.

If life serves you lemons, make lemonade
7 REPLIES 7
James R. Ferguson
Acclaimed Contributor

Re: Checking for $LOGNAME on another server

Hi:

Assuming remote shell is allowed/setup:

# remsh thehost grep username /etc/passwd

...or:

# remsh thehost finger username

Regards!

...JRF...
Jean-Louis Phelix
Honored Contributor

Re: Checking for $LOGNAME on another server

hi,

finger command would do it (see man finger). But fingerd must be enabled on the remote system which is not very secured ...

Regards.
It works for me (© Bill McNAMARA ...)
Jean-Louis Phelix
Honored Contributor

Re: Checking for $LOGNAME on another server

to enable fingerd, uncomment the line in /etc/inetd.conf then run inetd -c.

Regards.
It works for me (© Bill McNAMARA ...)
Leslie Chaim
Regular Advisor

Re: Checking for $LOGNAME on another server

Well, I was using pwget -n and it works fine. I guess I was looking for something fancy.

Now I am doing this:
exists=$(remsh omni pwget -n $LOGNAME)

test -n "$exists" || echo $LOGNAME is not in omni

I feel that doing the string checking is a bit awkword, nevertheless it does the job.

Here's a thought but I am not sure if this is possible, is there a way with mail/mailx/sendmail and some options where you can simply tickel the othere side and ask for if a user exists. This way the above can be done like this:

mail -option $LOGNAME@omni || echo $LOGNAME is not in omni
If life serves you lemons, make lemonade
Darren Prior
Honored Contributor

Re: Checking for $LOGNAME on another server

Hi,

If you're going to be using pwget -n I'd suggest that you check using the error code rather than testing for a string being returned. return code is 0 for found, 1 for not found, 2 for an error as per the man page.

Otherwise a different way of approaching this is to consider something like NIS to keep account authentication across different boxes.

regards,

Darren.
Calm down. It's only ones and zeros...
Leslie Chaim
Regular Advisor

Re: Checking for $LOGNAME on another server

Yes Darren, but the error code is lost with remsh:(
If life serves you lemons, make lemonade
Jean-Louis Phelix
Honored Contributor

Re: Checking for $LOGNAME on another server

Leslie,

I think that Darren meant something like :

[ -z $(remsh omni "pwget -n $LOGNAME >&- || echo 1" ) ] || echo $LOGNAME is not in omni

Regards
It works for me (© Bill McNAMARA ...)