过生日,也要学学哈,这次是SHELL的GETOPTS

时间:2023-03-09 15:08:44
过生日,也要学学哈,这次是SHELL的GETOPTS

今天是WEBSOCKET,,

先完成一个SHELL的GETOPS,周一就用得着。

#!/bin/bash

echo "usage: ./$0 -t (prism|opscripts)"

function scp_prism()
{
    echo "scp_prism()"
}

function scp_opscripts()
{
    echo "scp_opscripts()"
}

while getopts t:h  OPT
do
    case  $OPT in
    "t")
        TYPE=$OPTARG
        if [ $TYPE = "prism" ];then
            scp_prism
        fi
        if [ $TYPE = "opscripts" ];then
            scp_opscripts
        fi
        ;;
    "h")
        echo "./$0 -t (prism|opscripts)"
        ;;
    \?)
        echo "$0 -t (prism|opscripts)"
        exit -
    esac
done