shell经过wget
394
- 逸笙2019-03-24金牌会员126924
- 本帖最后由 逸笙 于 2019-3-24 16:16 编辑 *
LOC大佬多。
- while [ -z "${user}" ]
- do
- read -p "Input your account:" user
- done
- while [ -z "${pwd}" ]
- do
- read -p "Input your password:" pwd
- done复制代码
简单的几句,如果本地运行不会有问题,wget到本地后再bash也没有问题。
但如果打算wget -O- xxx.com/aaa.sh | bash,就有问题了,
首先是没有停下来输入user跟pwd,
然后提示:line 11: syntax error near unexpected token `do'
这个11行是第2个do,我echo user出来,它居然是> "这样三行,百度了半天,好像while是自己的小环境,给|一下后就会出错。那怎么实现呢,我想用户不输入user就继续提示输入,然后还想可以直接wget -O- 来 | bash这样。
==================
read -p "Input your password:" pwd < /dev/tty
感谢dupit8