免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 644 | 回复: 0
打印 上一主题 下一主题

脚本新手,请帮忙看是何问题! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-09-15 14:27 |只看该作者 |倒序浏览
[root@localhost root]# vi ./party

#!/bin/tcsh -f
# TC shell
# The Party Program--Invitations to friends from the "guest" file
set guestfile = ~/shell/guests
if (! -e "$guestfile" then
   echo "$guestfile:t non-existent"
   exit 1
endif
set env PLACE "Sarotini's"
@ Time= `date +%H` +1
set food = (cheese crackers shrimp drinks "hot dogs" sandwiches)
foreach person (`cat $guestfile`)
  if ($person = ~root)continue
#Start of here document
mail -v -s "arty" $person << FINIS
Hi ${person}! Please join me at $PLACE for a party!
Meet me at $Time o'clock.
I'll bring the ice cream. Would you please bring $food[1] and anything else you would like to eat? Let me know if you can't make
it. Hope to see you soon.
Your pal,
star@`hostname`
FINIS
shift food
if ($#food == 0)then
set food = (cheese crackers shrimp drinks "hot dogs" sandwiches)
end if
end
echo "Bye..."
                                                                                                                        
[root@localhost root]# ./party
set: Variable name must begin with a letter.

目的:向一系列用户发送信息。邀请他们参加一个party。party的时间和地点被存入变量,被邀请的人是从一个叫做guests的文件中选出来的。食物清单保存在一个单词列表里,每一个都要求从清单中选择一种食物。如时选择同样食物的用户多于该食物的项目数量,清单就被重置,每一个用户就被要求重新选择另一种食物。惟一没有被邀请的用户是root.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP