Discussion:
How to check if a user already login?
hezjing
2009-02-04 02:51:19 UTC
Permalink
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!
--
Hez
Amaresh Chandra Das
2009-02-04 05:53:35 UTC
Permalink
Hi Hez,

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

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

# 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
***@cvs


Help me , if i am wrong,

Thanks,
-Amaresh
"Walk with a hope in your heart....you will never walk alone"

--- On *Wed, 4/2/09, hezjing <***@gmail.com>* wrote:
From: hezjing <***@gmail.com>
Subject: How to check if a user already login?
To: info-***@nongnu.org
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!
--
Hez
Todd Denniston
2009-02-04 14:42:56 UTC
Permalink
Post by Amaresh Chandra Das
Hi Hez,
Please use this bellow command ,
if someone is logged in then you will get message like " \_ ssh
# ps ax |grep -i cvs
1057 pts/2 S+ 0:00 grep -i cvs
# 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
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
Post by Amaresh Chandra Das
Subject: How to check if a user already login?
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
hezjing
2009-02-07 02:25:55 UTC
Permalink
Hi

Todd's solution is working, to check from the ~/.cvspass.

To summary, when a user has not logged on to cvs:
$ grep "$CVSROOT" ~/.cvspass |awk '{print $3}'
$

After a user logged on to cvs:
$ grep "$CVSROOT" ~/.cvspass |awk '{print $3}'
A,>d^?=I"1
$


Thank everyone!

On Wed, Feb 4, 2009 at 10:42 PM, Todd Denniston <
Post by Todd Denniston
Post by Amaresh Chandra Das
Hi Hez,
Please use this bellow command ,
if someone is logged in then you will get message like " \_ ssh
# ps ax |grep -i cvs
1057 pts/2 S+ 0:00 grep -i cvs
# 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
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 ...
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
Post by Amaresh Chandra Das
Subject: How to check if a user already login?
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
--
Hez
Loading...