artjuh
30th October 2002, 17:42
I want to make an batch file so that some users can login multiple times and others can't
i know that i can use ipc_info for that but how.

i can make a newline in it like "user s 0 0 p ${BSE}/bin/userlogin"

But what should contain my script ? something like below ?

//Filename: ${BSE}/bin/userlogin

a=`licmon6.1 -w | grep $1`

if [ -n $a ]; then
${BSE}/bin/bshell6.1
else
${BSE}/bin/bshcmd $1 "Your already logged in"
fi

I also have no id what stdout ipc_info should give
maybe someone can tell how he did this.

Thanks in advanced,

Artjuh

victor_cleto
30th October 2002, 23:00
What we do is something like the following:

- your users must all use, instead of the bshell, the userlogin setup on their BW

- use a file, for example, $BSE/lib/userlogin.allow, where you store the nr. of logins each user is allowed to use, eg
bsp:10
root:5
...
If only one login is to be allowed, then this is not needed and replace down under the ALLOW with 1.

- for your userlogin script,
you need to get the current user, eg, USER=`whoami` or similar function that may be provided by the OS (above for HP-UX for example)

Since all users will be using that script, then just count the nr. of times the script userlogin is running for it, eg,
COUNT=$(ps -fu $USER|grep userlogin|grep -v grep|wc -l)
ALLOW=$(grep $USER $BSE/lib/userlogin.allow|cut -f2 -d":")
if [ $COUNT -le $ALLOW ] ; then
$BSE/bin/bshell6.1
else
... whatever you want here
fi

To send a message, you need first to get the current PID of the already running bshell, eg,
ps -fu $USER|grep bshell6.1|grep -v -grep|read A PID B
and then send the message to the $PID, not the user (check the usage of bshcmd6.1)

If you allow the user to login more than once, make that you send a message to all the bshell6.1's for that user.