查看“︁Ksh”︁的源代码
←
Ksh
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
=intro= The Korn Shell (ksh) is a Unix shell developed by David Korn in the early 1980s at Bell Labs. It was designed to combine the features of the Bourne Shell (sh) and the C Shell (csh), offering enhanced functionality for both interactive use and scripting. It is known for its performance efficiency and advanced scripting capabilities. =rerun= <pre> #!/usr/bin/ksh # myjob.ksh # 第一次启动时若未传入计数器,设成 0 (( TRY=${1:-0} )) # ====== 真正要做的事情 ====== # 这里用 grep 一个不存在的串来模拟失败 grep "never_exist" /etc/passwd >/dev/null RC=$? # ============================= if (( RC == 0 )); then print "Job OK" exit 0 else (( TRY++ )) if (( TRY < 2 )); then print "retry $TRY ..." exec $0 $TRY # 关键:把计数器传给自己,重新执行 else print "Failed after 2 tries" exit 1 fi fi 判断自己存在不存在的 好像 frg 用过 找一下 blog #run and test on kali shell chmod +x myjob.ksh ➜ shell ./myjob.ksh retry 1 ... retry 2 ... Failed after 2 tries 第一次手动执行时不给参数,脚本内部把 ${1:-0} 当成 0。 每次失败都会 exec $0 $TRY,进程号不变(不会累积后台进程)。 </pre> =task 1= == add new parms== 开始有 7个 最后一个为EXTRA_PARMS_LIST=$7 那我就得 加个$7 ,EXTRA_PARMS_LIST=$8 [[category:shell]]
返回
Ksh
。
导航菜单
个人工具
登录
命名空间
页面
讨论
大陆简体
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
我的导航
关于我
shell
python
ops
linuxchina.net
blog.linuxchina
最近更改
随机页面
帮助
工具
链入页面
相关更改
特殊页面
页面信息