Operating System - HP-UX
1833873 Members
4330 Online
110063 Solutions
New Discussion

Ring alarm through all logged in terminals

 
SOLVED
Go to solution
boomer_2
Super Advisor

Ring alarm through all logged in terminals

Hi Rasheed,Richard,
I had to open another thread for this issue....
What do i do if i want to ring the alarm bell from all logged in sessions anad not from the single/current session ...where should i run this script??
In the background/cron job ?
7 REPLIES 7
Luk Vandenbussche
Honored Contributor

Re: Ring alarm through all logged in terminals

Select all the users that are logged on to your system

who | awk -F " " '{print $2}'

Integrate this with your other script
boomer_2
Super Advisor

Re: Ring alarm through all logged in terminals

Hi Luk,
i tried it..but its not working..


echo "\a" > `who | awk -F " " '{print $2}'`
sh: pts/0^Jpts/1^Jpts/2^Jpts/3^Jpts/4^Jpts/6^Jpts/7^Jpts/8^Jpts/9^Jpts/10^Jpts/13^Jpts/14^Jpts/15^Jpts/16^Jpts/17^Jpts/18^Jpts/19^Jpts/20^Jpts/11^Jpts/21^Jpts/22^Jpts/23^Jpts/24^Jpts/26^Jpts/27^Jpts/28^Jpts/29^Jpts/30^Jpts/31^Jpts/32^Jpts/35^Jpts/36^Jpts/33^Jpts/39^Jpts/40^Jpts/42^Jpts/44^Jpts/45^Jpts/46^Jpts/47^Jpts/48^Jpts/49^Jpts/50^Jpts/51^Jpts/52^Jpts/53^Jpts/55^Jpts/56^Jpts/57^Jpts/60^Jpts/61^Jpts/65^Jpts/77^Jpts/79^Jpts/80^Jpts/83^Jpts/86: Cannot create the specified file.
John Payne_2
Honored Contributor

Re: Ring alarm through all logged in terminals

boomer,

I'm not sure that this will work, I don't see why it wouldn't, but could you pipe the thing to wall?

yourscript | wall

John
Spoon!!!!
Rasheed Tamton
Honored Contributor

Re: Ring alarm through all logged in terminals

Hi boomer,

It is a natural question we should expect!
will have to test it. As cron is not attached to a tty, it needs some trick. You could redirect that to another tty (/dev/ttyp1) which might always be opened on a pc, etc. Cron has no terminal attached to it, so reference to terminals has controlling issues - getting a logic is most important.

What is your real requirement - how do you want it to run.

For a test you can do

#cat alarm.sh
#!/usr/bin/ksh
count=0
while [[ $count -lt 10000 ]]
do
/usr/bin/echo "\a" > /dev/ttyp1
count=$(($count + 1))
done

Put the scipt on a cron for once and test it. Open a terminal and check it with tty command. And change the script according to it (ttyp1 to your avble ttyp?). If you are testing it on a workstation it is more easy. You can control the terminals. If it is on a server you have to be more careful.

Whatever you are doing on the tty at the time of running cron might be disrupted. If something goes wrong do a
ps -ef|grep echo
and kill the echo process.

May be others might join with this thread with more tricky options.

Regards,
Rasheed Tamton.
Luk Vandenbussche
Honored Contributor

Re: Ring alarm through all logged in terminals

who | awk -F " " '{print $2}' | while read line
do
echo "\a" > $line
done

Rasheed Tamton
Honored Contributor
Solution

Re: Ring alarm through all logged in terminals

#!/usr/bin/ksh
count=0
while [[ $count -lt 10000 ]]
TTYS=`/usr/bin/who |awk '/ty/{printf ("/dev/"$2"\n")}'`
do
/usr/bin/echo "\a" > $TTY
count=$(($count + 1))
done
boomer_2
Super Advisor

Re: Ring alarm through all logged in terminals

hi Rasheed,
i did the following and put it in cron ..its running absolutely fine for me...

#cat /tmp/check_bdf.sh
function check_bdf {
bdf -l | awk '$0 !~ /^F/' |awk '{if (NF!=1){
if (NF==5){
print $4"\t" $5"\t"
}
else{
print $5"\t\t" $6"\t"
}
}}' | sed 's/'%'/''/'
}

for i in `check_bdf |cut -f1`
do
if [ $i -ge 95 ]
then
/tmp/bell_all.sh
fi
done

# cat bell_all.sh

count=0

while [ $count -lt 10 ]
do

for i in `who|awk '{printf ("/dev/"$2"\n")}'`
do
echo "FILE SYSTEM FULL--------> PLZ CONTACT SYSTEM ADMINISTRATOR......" > $i
echo "\a" > $i
done

sleep 1
count=$(($count + 1))
done

And put it in cron to tun after every 10 min...in my development server..i m going to implement this in producn server as well..

Thanks for all of guys input..i could do this finally....