[billing_dx@bmcs1 pts]$ pwd /dev/pts [billing_dx@bmcs1 pts]$ ls 0 11 14 17 2 22 25 28 30 33 36 39 41 44 47 5 52 55 58 61 64 67 7 72 75 ptmx 1 12 15 18 20 23 26 29 31 34 37 4 42 45 48 50 53 56 59 62 65 68 70 73 8 10 13 16 19 21 24 27 3 32 35 38 40 43 46 49 51 54 57 60 63 66 69 71 74 9
[billing_dx@bmcs1 pts]$ who am i billing_dx pts/52 Feb 26 09:52 (172.28.0.194)
[billing_dx@bmcs1 pts]$ echo "hello" >/dev/pts/52 hello
#!/bin/bash # @file SendMsg.sh # @author ymm # @brief 给当前连接主机的终端群发信息 # @date 2014/2/26 11:33:47 # @History # 1 2014/2/26 11:33:47 author ymm 初步完成 if [ $# -ne 1 ];then echo "请输入要发送的内容:"; echo "eg:$0 hello" exit -1; fi Dir=/dev/pts/ for pts in $(ls $Dir) do echo $1 >${Dir}/${pts} done
通过上面的方式,就可以和连接主机的所有终端发送信息了。
shell脚本 给linux上的用户群发信息,布布扣,bubuko.com
原文:http://blog.csdn.net/yang15225094594/article/details/19971763