linux中shell指令碼登入註冊小案例

2021-10-08 17:48:47 字數 1021 閱讀 4212

登入註冊 要求:01.註冊時需要判斷user是否存在,不存在寫入檔案,存在告知。 輸入兩次密碼要一致。使用者名稱的長度不小於3,密碼長度不小於6

02.登陸時,使用者名稱和密碼完全匹配,返回登陸成功。

#!/bin/bash

echo 1.註冊

echo 2.登入

echo 3.退出

read -p "請輸入選擇": num

case $num in

1)echo "歡迎來到註冊介面"

read -p "請輸入使用者名稱": user

read -p "請輸入密碼": password

read -p "請輸入密碼": password2

while read line

donuser=`echo $line | cut -d ":" -f 1`

if [ "$user" == "$nuser" ];then

echo "使用者名稱已存在"

exit 1

fidone < /yubo/shell/wenjian.txt

if [ "$" -ge 3 -a "$" -ge 4 ]

then

if [ "$" == "$" ]

then

echo "$:$" >> /yubo/shell/wenjian.txt

echo "恭喜你註冊成功"

else

echo "兩次密碼不一致"

fifi

;;2)

echo "歡迎來到登入介面"

read -p "請輸入使用者名稱": luser

read -p "請輸入密碼": lpassword

up="$:$"

lines=`cat /yubo/shell/wenjian.txt | wc -l`

i=1while read line

doif [ "$" == "$" ]

then

echo "登入成功"

exit 0

Shell 自動登入指令碼

配置檔案最終轉化成了陣列,相關資訊與 強耦合。需要的可以根據自己喜好修改配置檔案格式和 users wangjia bin ssh conf server.conf id desc username outsite ip insite ip connect type key path passwor...

shell指令碼登入sftp

sftp不能像ftp一樣直接使用賬號 密碼登入 ftp ip位址 user 賬戶 密碼 需要互動式輸入登入密碼。在shell中可以使用expect 傳入密碼。sftp rad.put bsf user bsf ip expect yes no 也可以使用 ssh keygen t rsa 生成公私鑰...

linux中除錯shell指令碼

原來的指令碼check.sh monfile var log test testmon.txt logfile var log test testmon.log touch monfile 該指令碼是在window裡編輯的,編輯後上傳到linux的 問題 執行後,目錄下出現的檔案是testmon.t...