Shell Script Demonstrate Communication Command | Linux Rhel5 Command

Bash shell script communicate command motd wall
To demonstrate communication command.
Description:
Command Used Description
motd   Used to show message of the day.
wall     Used to send message to every user.
write   Used to send message to other user who logged in.
mesg   Used to deny or accept message.
talk Used to carry on a two-way communication.
Bash Shell script Communicate command motd write mesg talk
# Communication command script.

# print message of the day.
echo "Below is the Message of the Day"
motd

# send wall message. wall message is sent to every user.
echo "Sending wall message about beginning of some work..."
wall << EOF
There is a system backup starting in one minute!
Please save all of your work now, and please
refrain from modifying any files until the back
is complete!
EOF

# write command. sends message to a user on a specific terminal.
lognm=`logname`
ttynm=`who -a | grep rhel5 | tail -1 | awk -F" " '{print $3}'`
echo "Writing message to user: $lognm on terminal: $ttynm"
echo ""
write $lognm $ttynm <<EOF
Hello,
How are you?
Bye
EOF
echo ""
echo "Message for user: $lognm sent on terminal: $ttynm"

# mesg command. see whether control access to terminal is allowed or not.
ctrlacc=`mesg`
echo ""
echo "Control access to this terminal $ctrlacc"
echo ""
echo "Disallowing access to this terminal"
mesg n < /dev/$ttynm
ctrlacc=`mesg`
echo ""
echo "Control access to this terminal $ctrlacc"
mesg y < /dev/$ttynm
ctrlacc=`mesg`
echo ""
echo "Resetting control access to this terminal to $ctrlacc"

# press a key to proceed to talk session
echo ""
echo "Press any key to enter talk session"
read x

# talk session start
echo "Talk session starting with user: $lognm"
talk $lognm $ttynm

Bash Shell script output of Communication Linux command
Sending wall message about beginning of some work...
Broadcast message from rhel5 (Thu Apr 15 23:50:19 2010):
There is a system backup starting in one minute!
Please save all of your work now, and please
refrain from modifying any files until the back
is complete!

Writing message to user: rhel5 on terminal: pts/4
Message from rhel5@adc2180738 on pts/4 at 16:50 ...
Hello,
How are you?
Bye
EOF
Message for user: rhel5 sent on terminal: pts/4
Control access to this terminal is y
Disallowing access to this terminal
Control access to this terminal is n
Resetting control access to this terminal to is y
Press any key to enter talk session
CONCLUSION: The following bash shell script demonstrate the communication rhel5 commands.

Post a Comment

0 Comments