- 论坛徽章:
- 1
|
场景:
由于工作需要,我要做个脚本,暂且命名为 main.sh ,main.sh中的内容是:
sh /home/examples/read.sh 就这一行内容
read.sh 中的内容为:
#!/bin/bash
read -p "username:" user
echo $user
read -p "password:" -s passwd
echo -e"\n$passwd"
目的很简单为了屏蔽passwd的内容,所以加了-s参数
问题:
当我运行main.sh时出现这样的错误
root@server:/home/examples# ./main.sh
username:root
root
read: 4: Illegal option -s
root@server:/home/examples# bash --version
GNU bash, version 4.0.33(1)-release (i486-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>;
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
root@server:/home/examples# uname -ra
Linux server.example.com 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux
如果我单独运行 read.sh 不会报错,请问各位大侠什么原因? 还有另求更好的方法隐藏输入方法,望各位不吝赐教~ |
|