欢迎访问范文网!

简单的脚本范文(优选3篇)

投稿:笔杆子 收藏 下载文档

简介:范文网小编为你整理了多篇相关的《简单的脚本范文(优选3篇)》,但愿对你工作学习有帮助,当然你在范文网还可以找到更多《简单的脚本范文(优选3篇)》。

简单的脚本范文 第1篇

以下是重启Linux下某进程的shell脚本,以tomcat进程为例:

#!/bin/shpid=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`if [ “$pid” = “” ] ; then echo “tomcat service does not start!”else kill -9 $pid pid1=`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'` if [ “$pid1” = “” ] ; then echo “Successfully kill tomcat processes: ” $pid else echo “tomcat kill process failed!” exit 1 fifirm -rf /opt/tomcat/work/*./`ps -ef|grep tomcat|grep -v grep|awk '{print $2}'`if [ “$pid2” = “” ] ; then echo “tomcat service failed to start!”else echo “tomcat service starts successfully:” $pid2fi

简单的脚本范文 第2篇

#!/bin/sh

# -- 一个看起来像是bc的前端的命令行计算器

scale=2

show_help

cat << EOF

In addition to standard math function, calc also supports

a % b  remainder of a/b

a ^ b  exponential: a raised to the b power

s(x)  sine of x, x in radians

c(x)  cosine of x, x in radians

a(x)  actangent of x, returns radians

l(x)  natural log of x

e(x)  exponential log of raising e to the x

j(n, x) bessel function of integer order n of x

scale N show N fractional digits(default = 2)

EOF

if [ $# -gt 0 ]; then

exec “$@”

echo “Calc - a simple calculator. Enter 'help' for help, 'quit' to quit.”

echo -n “calc> ”

while read command args  # 像不像Python的顺序解包

case $command in

quit|exit) exit 0;;

help|?) show_help;;

scale)  scale=$args;;

*)     -p $scale “$command” “$args”;;

esac

echo -n “calc> ”

done

echo “”

exit 0

脚本如何运行:

可能这个脚本最有意思的部分就是那个while循环了,

交互式计算器脚本

它创建一个calc>的提示,直到用户完成输入。当然,这个脚本的间接性成就了它自己:shell脚本并不需要特别的复杂。

运行脚本:

这个脚本跑起来非常简单,因为它是一个交互式的,可以提示用户完成特定操作。如果有参数传递给它,它就转而把这些参数传给。

运行结果:

calc 150 /

Calc - a simple calculator. Enter 'help' for help, 'quit' to quit.

calc> help

In addition to standard math function, calc also supports

a % b  remainder of a/b

a ^ b  exponential: a raised to the b power

s(x)  sine of x, x in radians

c(x)  cosine of x, x in radians

a(x)  actangent of x, returns radians

l(x)  natural log of x

e(x)  exponential log of raising e to the x

j(n, x) bessel function of integer order n of x

scale N show N fractional digits(default = 2)

calc> 54354 ^ 3

160581137553864

calc> quit

简单的脚本范文 第3篇

1111111111111清除/var/log下messages日志文件的简单命令脚本

…… 此处隐藏1290字,全部文档请下载后查看。喜欢就下载吧 ……

简单的脚本范文(优选3篇)

简单的脚本范文(优选3篇)。下面小编给大家分享简单的脚本范文(优选3篇),希望能帮助到大家。 简单的脚本范文(优选3篇)文档下载网址链接:
推荐度:
点击下载文档文档为docx格式

该篇《简单的脚本范文(优选3篇)》范文为DOC格式,范文网为全国知名范文网站,下载本文后稍作修改便可使用,即刻完成写稿任务。网址:https://www.zhsm.net/a/c16mwqn.shtml

精选图文

221381
领取福利

微信扫码领取福利

简单的脚本范文(优选3篇)

微信扫码分享