Regarding who command

Hi,

Currently we r restricting the user's to access only one session using the who command.
Command we used

count=`w | grep -c "$LOGNAME "` or count=`who | grep -c "$LOGNAME "`
let count=$count
if (( $count > 1 )); then
echo "restricted"

But the problem is, It is counting the FTP Session also.
Can anyone help us to provide the solution?

Are you talking about local sessions, remote sessions or what?

Yes.

Example,

Now i didn't opent the FTP Session
kganeshb@its04487:~ $ who | grep "kganeshb"
kganeshb pts/18 Mar 27 16:06 (its100267mq1s.chennai.ford.com)
kganeshb pts/35 Apr 2 10:00 (its100477mq1s.chennai.ford.com)
kganeshb pts/29 Apr 2 09:55 (its100477mq1s.chennai.ford.com)
kganeshb pts/62 Apr 2 12:28 (its100477mq1s.chennai.ford.com)

With FTP Session

kganeshb pts/18 Mar 27 16:06 (its100267mq1s.chennai.ford.com)
kganeshb pts/35 Apr 2 10:00 (its100477mq1s.chennai.ford.com)
kganeshb pts/29 Apr 2 09:55 (its100477mq1s.chennai.ford.com)
kganeshb pts/62 Apr 2 12:28 (its100477mq1s.chennai.ford.com)
kganeshb vsftpd:17924 Apr 2 14:28 (19.237.45.119)

In unix, who command doesn't count the ftp session but in the Linux it is counting.

Try this:

count=`who | grep -v 'ftp' |grep -c "$LOGNAME "`
let count=$count
if (( $count > 1 )); then
echo "restricted"

Solution i know, i want the reason why the same problem doesn't occur for unix.