当前位置: 首页 > news >正文

文章类型的网站模版旅行社网站制作

文章类型的网站模版,旅行社网站制作,网站建设哪家g好,万载网站建设运维Shell脚本小试牛刀(一) 运维Shell脚本小试牛刀(二) 运维Shell脚本小试牛刀(三)::$(cd $(dirname $0)#xff1b; pwd)命令详解 运维Shell脚本小试牛刀(四): 多层嵌套if...elif...elif....else fi_蜗牛杨哥的博客-CSDN博客 Cenos7安装小火车程序动画 运维Shell脚本小试… 运维Shell脚本小试牛刀(一) 运维Shell脚本小试牛刀(二) 运维Shell脚本小试牛刀(三)::$(cd $(dirname $0) pwd)命令详解 运维Shell脚本小试牛刀(四): 多层嵌套if...elif...elif....else fi_蜗牛杨哥的博客-CSDN博客 Cenos7安装小火车程序动画 运维Shell脚本小试牛刀(五):until循环 运维Shell脚本小试牛刀(六): Shell中的函数认知 运维Shell脚本小试牛刀(七):从函数文件中调用另外一个脚本文件中函数 简介: 从函数文件中调用函数 你可以把所有的函数存储在一个脚本文件 你可以把所有的函数加载到当前脚本文件或者时命令行 加载函数文件的所有函数的语法如下: . /path/to/your/functions.sh 一: 编写函数文件 [rootwww dicfor]# cat myfunctions.sh # # # #                           FILE:  myfunctions.sh #                           USAGE: ./myfunctions.sh #    DESCRIPTION:   函数定义从函数文件中调用函数,可以把所有的函数存储在一个文件中,然后把所有的函数加载到当前脚本或是命令行 #        OPTIONS: ------- #        REQUIREMENTS: --------- #  #        BUGS: ------ #        NOTES: --------  #        AUTHOR: ---------YangGe (TOM) ,YangGe.freedomicloud.com #    ORGANIZATION: #        CREATED: 2023-8-24 09:11:20     #        REVISION: -------- # # # # # # # 加载函数文件中的所有函数的语法如下: . /path/to/your/functions.sh # 定义变量 declare -r TRUE0 declare -r FALSE0 declare -r PASSWD_FILE/etc/passwd ################################################################################################################### # #   用途: 将字符串转换为小写 #     参数 #       $1 - 要转换为小写的字符串 # # # # #################################################################################################################### function to_lower() {   # 定义一个本地变量str   local str$   # 定义本地变量output   local output   # 将变量str的值转换为小写符赋值给变量output   output$(tr [A-Z] [a-z] ${str})   echo $output } ################################################################################################################### # #   用途: 如果脚本root用户执行则返回true #     参数 无 #   返回值: True或者Flase # # # # #################################################################################################################### function is_root() {   # 如果运行此脚本的账号的uid等于0,则返回0,否则返回1   [ $(id -u) -eq 0 ] return $TRUE || return $FALSE } ################################################################################################################### # #   用途: 如果用户名存在于文件/etc/passwd 中则返回true #     参数 #       $1 (用户名) - 要在文件/etc/passwd 中检查的用户名 #       返回值: True 或者 False # # # # #################################################################################################################### function is_user_exits() {    # 定义本地变量u    local u$1    # 如果文件/etc/passwd中存在以变量$u的值为开头的行,则返回0,否则返回1    grep -q ^${u} $PASSWD_FILE return $TRUE || return $FALSE }   二: 加载函数文件到当前shell环境 [rootwww dicfor]# pwd /usr/local/example/dicfor [rootwww dicfor]# . /usr/local/example/dicfor/myfunctions.sh -bash: declare: TRUE: 只读变量 -bash: declare: FALSE: 只读变量 -bash: declare: PASSWD_FILE: 只读变量   三 编写加载myfunctions.sh函数文件的脚本文件  [rootwww dicfor]# cat myfunctionsdemo.sh  # # # #                           FILE:  functionsdemo.sh #                           USAGE: ./functionsdemo.sh #    DESCRIPTION:   函数定义在该文件中加载一个函数文件myfunctions.sh到该脚本文件中 #        OPTIONS: ------- #        REQUIREMENTS: --------- #  #        BUGS: ------ #        NOTES: --------  #        AUTHOR: ---------YangGe (TOM) ,YangGe.freedomicloud.com #    ORGANIZATION: #        CREATED: 2023-8-24 09:11:20     #        REVISION: -------- # # # # # # # 加载函数文件myfunctions.sh # 这里的路径需要根据你的实际环境作出跳转. /usr/local/example/dicfor/myfunctions.sh # 定义本地变量 # var1时没有被myfunctions.sh使用的 var1The Mahabharata is the longest and,arguably,one of the greatest epicpoems is any language.. # 调用函数is root , 指定成功或失败,会分别打印不同的信息is_root echo You are logged in as root. || echo You are not logged in as root # 调用函数is_use_exits is_user_exits mysql echo Account found. || echo Account not found. # 打印变量的值var1 echo -e *** Orignal quote: \n${var1}  # 调用函数to_lower() # 将#var1 作为参数传递给to_lower() # 在echo 内使用的命令替换 echo -e *** Lowercase version: \n$(to_lower ${var1})   四: 执行该脚本|看看该脚本是否已调用引入的脚本函数 [rootwww dicfor]# ./myfunctionsdemo.sh  You are logged in as root. Account found. *** Orignal quote: The Mahabharata is the longest and,arguably,one of the greatest epicpoems is any language.. *** Lowercase version: the mahabharata is the longest and,arguably,one of the greatest epicpoems is any language.. 五 函数递归调用  [rootwww functiondic]# cat functionnestedCalled.sh  # # # #                           FILE:  functionNestedCalled.sh #                           USAGE: ./functionNestedCalled.sh #    DESCRIPTION:  Shell中函数递归调用 #        OPTIONS: ------- #        REQUIREMENTS: --------- #  #        BUGS: ------ #        NOTES: --------  #        AUTHOR: ---------YangGe (TOM) ,YangGe.freedomicloud.com #    ORGANIZATION: #        CREATED: 2023-8-24 09:11:20     #        REVISION: -------- # # # # # # # 定义函数factorial()--计算给定命令行参数的阶层 function factorial {   # 定义本地变量i   local i$1   # 定义本地变量f   local f   # 声明变量为整数   declare -i i   # 声明变量f为整数   declare -i f   # factorial 函数被调用,只到调用$f的值-2   # 开始递归  [ $1 -le 2 ] echo $i || { f$(( i - 1)); f$(factorial $f); f$(( f * i )); echo ${f}; }  } # 显示函数用法 [ $# -eq 0 ]  { echo Usage: $0 number; exit 1; } # 调用函数factorial factorial $1   执行脚本 [rootwww functiondic]# ./functionnestedCalled.sh  Usage: ./functionnestedCalled.sh number [rootwww functiondic]# ./functionnestedCalled.sh 2 2 [rootwww functiondic]# ./functionnestedCalled.sh 4 24 [rootwww functiondic]# ./functionnestedCalled.sh 24 -7835185981329244160 [rootwww functiondic]# ./functionnestedCalled.sh 10 3628800   六:  Shell脚本函数后台执行 [rootwww functiondic]# cat saemoncalledFunction.sh  # # # #                           FILE:  saemoncalledFunction.sh #                           USAGE: ./saemoncalledFunction.sh #    DESCRIPTION:  Shell 中函数放在后台执行 #        OPTIONS: ------- #        REQUIREMENTS: --------- #  #        BUGS: ------ #        NOTES: --------  #        AUTHOR: ---------YangGe (TOM) ,YangGe.freedomicloud.com #    ORGANIZATION: #        CREATED: 2023-8-24 09:11:20     #        REVISION: -------- # # # # # # # 定义函数progress,显示进度条 progress(){  echo -n $0: Please wait..............   # 执行无限while循环   while true   do     echo -n .     # 休眠5秒     sleep 5   done } # 定义函数dobackup dobackup(){  # 运行备份命令  tar -zcvf /dev/st0 /home /dev/null 21 } # 将函数放在后台运行 progress # 保存函数progress()运行的进程号 # 需要使用PID来结束此函数 MYSELF$! # 开始备份 # 转移控制到函数dobackup dobackup # 杀死进程 kill $MYSELF /dev/null 21 echo -n .....done. echo   脚本执行效果 [rootwww functiondic]# ./saemoncalledFunction.sh  ./saemoncalledFunction.sh: Please wait.....................done.
http://www.pierceye.com/news/333302/

相关文章:

  • 北京市保障房建设投资中心网站瘫痪广州大型网站建设公司排名
  • 做电池网站的引导页室内设计联盟效果图
  • 查询备案网站成绩查询系统网站开发
  • 网站后台编辑器上传不了图片建筑工程承包网app
  • wordpress多站点插件168工程信息网
  • 网站工信部备案号没有ftp wordpress
  • 家装公司网站建设网站建立网站有免费的吗
  • 网站后台添加投票系统wordpress mip改造
  • 提升网站建设品质信息设计软件排行
  • 温州网站建设优化公司网站营销管理培训班
  • 昆明企业网站开发深圳航空公司最新官网
  • 青浦网站开发泸州建设网站
  • 福建省建设行业企业资质查询网站企业数据查询网站
  • wordpress 英文企业站东城手机网站制作
  • 搭建企业网站需要什么微商城系统网站模板
  • 班级网站怎样做ppt模板免费素材
  • 网站建设及运营 多少钱域名抢注哪个平台好
  • 抚顺营销型网站建设吴江开发区人才网
  • 余姚建设网站wordpress百度分享插件
  • iis网站服务器 建立出现问题吉林市城市建设档案馆官方网站
  • wordpress网站图片迁移打开一个网站为繁体字是怎么做的
  • 东莞规划局官方网站做网站要学一些什么
  • 网站动效是代码做的吗网站模板侵权问题
  • 网站开发语言总结有哪些怎么样让网站宣传自己
  • 网站建设公司哪家好找建设网站公司哪家好
  • 网站建设网上学a8直播免费版
  • 网上下载的免费网站模板怎么用灯箱网站开发
  • 四平市建设局网站贵州省民贸民品企业信息管理系统
  • 周口网站制作公司哪家好河南省信息服务平台官网
  • 然后建设自营网站湘潭市优化办