info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to check if a user already login?


From: Todd Denniston
Subject: Re: How to check if a user already login?
Date: Wed, 04 Feb 2009 09:42:56 -0500
User-agent: Thunderbird 2.0.0.19 (X11/20081209)

Amaresh Chandra Das wrote, On 02/04/2009 12:53 AM:
Hi Hez,

Please use this bellow command ,
if someone is logged in then you will get message like " \_ ssh
address@hidden"

# ps ax |grep -i cvs
 1057 pts/2    S+     0:00 grep -i cvs
28728 pts/3    S+     0:00 ssh address@hidden

# ps axfj |grep -i cvs
28076 30359 30358 28005 pts/2    30358 S+       0   0:00  |           \_
grep -i cvs
28526 28728 28728 28437 pts/3    28728 S+       0   0:00              \_ ssh
address@hidden


Help me , if i am wrong,


I believe the above is wrong, in the context of the question asked.
To me, hezjing asked how to see if `cvs login` had been done, so that scripts which are being written could check prior to making cvs calls, perhaps in the hope of not doing something wrong later in the script because of the repo not being available to the script.

Assuming the user actually has a password on the server...
Assuming the repository is using pserver (you really should use ssh)
On a Unix machine the easiest way is to
export xorpw=`grep "$CVSROOT" ~/.cvspass |awk '{print $3}'`
if [ "$xorpw" != "A" ]
then
   LOGEDIN=true
else
   LOGEDIN=false
fi
echo $LOGEDIN

I am not sure where CVSNT|WINCVS hide their .cvspass file.

with ssh ...
Assuming:
A) $CVSROOT does not have a FQDN
B)  hostname on the server does not return a FQDN
C) no username in $CVSROOT
or
D) both $CVSROOT and hostname will give you the same FQDN
If the above assumptions are wrong then script around them, you are after all writing scripts. :)
MACHINE=`echo $CVSROOT |awk -F: '{print $3}'`
FROMMACHINE=`ssh $MACHINE hostname 2>/dev/null`
if [ "$FROMMACHINE" == "$MACHINE" ]
then
   LOGEDIN=true
else
   LOGEDIN=false
fi
echo $LOGEDIN



--- On *Wed, 4/2/09, hezjing <address@hidden>* wrote:
From: hezjing <address@hidden>
Subject: How to check if a user already login?
To: address@hidden
Date: Wednesday, 4 February, 2009, 8:21 AM

Hi
I'm required to write a script to automate some CVS commands.

Is there a CVS command to check if a user has already login?


One way to do this is to execute a CVS command (e.g. cvs log or checkout)
and observe the errors,
but is there a more elegant way?


Thank you!



--
Todd Denniston
Crane Division, Naval Surface Warfare Center (NSWC Crane)
Harnessing the Power of Technology for the Warfighter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]