执行脚本时传递密码参数方式
#!/bin/bash
sh ./exec_impl.sh thinkmar 1>/dev/null 2>&1 << EOF
ThinkMarPwd
EOF
具体执行脚本中获取密码
#!/bin/bash
INPUT_PWD=""
read -p "Enter Password :" INPUT_PWD
sleep 15;
echo "[`date`],user_name=$1,user_pwd=$INPUT_PWD" > ./result.txt;
执行
pm22:~ # sh exec_main.sh
搜索执行脚本参数情况
pm22:~ # ps -ef | grep exec_impl
root 9465 9464 0 09:36 pts/0 00:00:00 sh ./exec_impl.sh thinkmar
root 14519 7390 0 09:36 pts/2 00:00:00 grep exec_impl
结果,参数传递正确
pm22:~ # cat result.txt
[Thu Jul 27 09:37:03 CST 2017],user_name=thinkmar,user_pwd=ThinkMarPwd