利用expect创建用户,并生成该用户密码对 利用数组统计80端口各链接状态数量 循环打印菜单并选择

  

 

#!/bin/env bash

username=$1

{
    id $username
    [[ $? -ne 0 ]] && useradd --comment '$username' $username && echo $username|passwd --stdin $username
} >& /dev/null

/usr/bin/env expect <<-EOF
    spawn su - $username
    
    expect "$"
    send "mkdir -pv .ssh\n"
    send "ssh-keygen -P '' -t rsa -f .ssh/id_rsa -C '$username_key'\n"
    expect eof
    EOF

 

#!/bin/env bash

declare -A rigor
for i in `ss -tanpe|grep :80|cut -d' ' -f1`;do
    let rigor[$i]++
done

for i in ${!rigor[*]};do
    echo $i:${rigor[$i]}
done

 

#!/bin/env bash

function menu(){
    cat <<-EOF
    *****************miscellaneous******************8
    h show help
    f fdisk
    d lsmem
    u uptime
    q quit
    **************************************************
    EOF
}

menu

while :;do
    read -t 10 -n 10 -s -p 'pppppppppp:' rigor
    echo
    case $rigor in
    h|help)
        menu
        ;;
    f|fdisk)
        fdisk -l
        ;;
    d|mem)
        lsmem
        ;;
    u|uptime)
        uptime
        ;;
    q|quit|exit)
        exit 5
        ;;
    *)
        echo 'miscellaneous systematic'
        ;;
    esac

    menu

    #read -t 10 -n 10  -p 'zzzzzzzzzzzzzzz:' rigor
done

 

posted @ 2021-05-09 11:47  ascertain  阅读(58)  评论(0编辑  收藏  举报