怎么样用write给所有的用户留言

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
hellojinjie
帖子: 1150
注册时间: 2007-09-14 21:03
来自: 浙江

怎么样用write给所有的用户留言

#1

帖子 hellojinjie » 2009-04-15 21:56

我的代码是这样的

代码: 全选

for i in `who`;do write `awk '{print $1, $2}'` <<< hi; done
但这是错误的
Say hello to everyday!
头像
qqttdh
帖子: 896
注册时间: 2007-07-20 22:15

Re: 怎么样用write给所有的用户留言

#2

帖子 qqttdh » 2009-04-15 22:37

居然。。。这么复杂。。。

代码: 全选

sudo -s
for i in `who|awk '{print $1$2}'|sed s/tty/_tty/`;do write `echo $i|awk -F '_' '{print $1,$2}'` <<<hello\! ;done
发言并不是一种义务,最喜欢的回答是不知道
两个手指点击,居然默认就是鼠标中键功能
右上角是中键,右下角是左键
Grub真小,才512B
零度电子书(Unix&Linux)
http://books.05sun.com/downlist/s_62_3.html
win7恢复能力不如xp,ubuntu相对较稳定。。。待机恢复起来似乎。。。
头像
qqttdh
帖子: 896
注册时间: 2007-07-20 22:15

Re: 怎么样用write给所有的用户留言

#3

帖子 qqttdh » 2009-04-15 22:41

其实wall也蛮好用的。。。
发言并不是一种义务,最喜欢的回答是不知道
两个手指点击,居然默认就是鼠标中键功能
右上角是中键,右下角是左键
Grub真小,才512B
零度电子书(Unix&Linux)
http://books.05sun.com/downlist/s_62_3.html
win7恢复能力不如xp,ubuntu相对较稳定。。。待机恢复起来似乎。。。
头像
hellojinjie
帖子: 1150
注册时间: 2007-09-14 21:03
来自: 浙江

Re: 怎么样用write给所有的用户留言

#4

帖子 hellojinjie » 2009-04-15 22:51

没有权限用 wall

你没有考虑pts的情况哦,就是用ssh登陆的时候不是tty

代码: 全选

who | awk '{print $1, $2}' | while read line; do write "$line" <<< hi ; done
可是输出还是错的。

代码: 全选

happy everyday ~$ who | awk '{print $1, $2}' | while read line; do write "$line" <<< hi ; done
write: catigger pts/0 is not logged in
write: unicode1985 pts/1 is not logged in
write: chenkai036 pts/2 is not logged in
write: wangjiangb pts/3 is not logged in
write: kevinqcs pts/4 is not logged in
write: hellojinjie pts/5 is not logged in
write: zhys9 pts/6 is not logged in
write: asiasoft pts/7 is not logged in
write: wshcdr pts/8 is not logged in
write: unmisha pts/9 is not logged in
write: mybays pts/10 is not logged in
write: warmbupt pts/11 is not logged in
write: Flameshark pts/12 is not logged in
write: davechenww pts/13 is not logged in
write: yongjh pts/14 is not logged in
write: joecgs pts/15 is not logged in
write: jeff613 pts/21 is not logged in
write: spectre pts/22 is not logged in
write: yindajun pts/23 is not logged in
Say hello to everyday!
头像
hellojinjie
帖子: 1150
注册时间: 2007-09-14 21:03
来自: 浙江

Re: 怎么样用write给所有的用户留言

#5

帖子 hellojinjie » 2009-04-15 22:53

代码: 全选

happy everyday ~$ who | awk '{print $1, $2}' | while read line; do eval write "$line" <<< hi ; done
OK 搞定,就是不知道,跟我同一个机器的人有没有收到我的消息,,,,,呜呜,我发了这么多,没一个人回复的。。
Say hello to everyday!
头像
qqttdh
帖子: 896
注册时间: 2007-07-20 22:15

Re: 怎么样用write给所有的用户留言

#6

帖子 qqttdh » 2009-04-18 14:29

原来fifo和文件一样是按行read的。。。一只没注意。。。呵呵
发言并不是一种义务,最喜欢的回答是不知道
两个手指点击,居然默认就是鼠标中键功能
右上角是中键,右下角是左键
Grub真小,才512B
零度电子书(Unix&Linux)
http://books.05sun.com/downlist/s_62_3.html
win7恢复能力不如xp,ubuntu相对较稳定。。。待机恢复起来似乎。。。
头像
jioyo源
帖子: 3476
注册时间: 2008-10-08 13:48

Re: 怎么样用write给所有的用户留言

#7

帖子 jioyo源 » 2009-04-25 20:22

:em20 灌水??
--------------------------------------
论坛精华贴全集:http://forum.ubuntu.org.cn/viewtopic.php?f=48&t=199845
book:http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=198286
头像
hellojinjie
帖子: 1150
注册时间: 2007-09-14 21:03
来自: 浙江

Re: 怎么样用write给所有的用户留言

#8

帖子 hellojinjie » 2009-04-25 21:27

jioyo源 写了::em20 灌水??
咱这是高科技灌水
Say hello to everyday!
头像
jioyo源
帖子: 3476
注册时间: 2008-10-08 13:48

Re: 怎么样用write给所有的用户留言

#9

帖子 jioyo源 » 2009-04-26 1:08

:em43 落后了,一直用双手加键盘灌来着……
--------------------------------------
论坛精华贴全集:http://forum.ubuntu.org.cn/viewtopic.php?f=48&t=199845
book:http://forum.ubuntu.org.cn/viewtopic.php?f=21&t=198286
回复