請教一個互動式的shell怎麼寫?
請教一個互動式的shell怎麼寫?
例如我要寫一個添加用戶shell,其他人只要執行這個腳本,就能根據自己需要,輸入用戶名和密碼,完成操作!怎麼寫呢
《解決方案》
人呢,版主呢,救命呢
《解決方案》
樓主去shell版提問下吧
《解決方案》
shell不支持。用python吧。
《解決方案》
read -p "enter username & password:" user passwd
《解決方案》
用expect 這個可以寫!具體的,自己可以去找下資料!
《解決方案》
回復 1# davie5201314
使用expect 來交互
#!/usr/bin/expect
set user {YOUR_USER_NAME}
set password {YOUPASSWOD}
《解決方案》
#!/bin/bash
read -p "input user name :" username
read -p "input user password :" userpwd
useradd $username
echo $userpwd | passwd --stdin $username
《解決方案》
回復 8# linux曾
這個不錯,謝謝了
《解決方案》
本帖最後由 ulovko 於 2012-07-26 09:52 編輯
linux曾 發表於 2012-07-04 00:16 static/image/common/back.gif
#!/bin/bash
read -p "input user name :" username
read -p "input user password :" userpwd
#!/bin/bash
read -p "input user name :" username
read -p "input user password :" userpwd
useradd $username
echo $userpwd | passwd --stdin $username
建議密碼部分改為:
read -s -p "input user password :" userpwd