zoukankan      html  css  js  c++  java
  • shell框架

    #!/bin/bash
    #注释
    #注释
    #环境变量相关,如下
    PATH=/sbin:/bin:/usr/bin:/usr/sbin

    #引入库函数,如下,类似于c语言的#include "*.h"

    . /etc/init.d/functions

    #获取相关配置信息,不是必须的,如
    test -f /etc/sysconfig/network && . /etc/sysconfig/network

    #判断是否是root用户,如果不是就退出
    [ `id -u` = 0 ] || exit 1

    #定义本地变量,如
    prog="xinetd"

    #定义shell函数,如
    stop(){
    echo -n $"Stopping $prog: "
    killproc $prog
    RETVAL=$?
    echo
    rm -f /var/lock/subsys/xinetd
    return $RETVAL

    }

    #shell脚本主框架,一般是一个case结构或者循环结构
    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    status)
    status $prog
    ;;
    restart)
    restart
    ;;
    reload)
    reload
    ;;
    condrestart)
    condrestart
    ;;
    *)
    echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
    RETVAL=1
    esac
    #退出

  • 相关阅读:
    CodeForces 514B
    CodeForces 514A
    UVa 818
    HDU 1003
    UVa百题总结
    UVa 11526
    UVa 12412
    UVa 211
    UVa 1587
    UVa 225 – Golygons [DFS+剪枝]
  • 原文地址:https://www.cnblogs.com/NiceTime/p/8561581.html
Copyright © 2011-2022 走看看