曾遇到这样一段代码:(Bash脚本)
1
2
3
4
5
6
7
8
9
10
11
12
|
#!/usr/bin/expect -f set HOST "192.168.102.1" set USER "codefor" set PASS "codefor" set BOOKFILE "/home/codefor" #upload spawn "scp *.zip $USER@$HOST:$BOOKFILE" expect { "*password*" {send "$PASS
" ;} } expect eof; |
这样的话,会报不存在*.zip的错误,即不能解析通配符*
在命令前加上bash -c即可。
如下:
1
2
3
4
5
6
7
8
9
10
11
12
|
#!/usr/bin/expect -f set HOST "192.168.102.1" set USER "codefor" set PASS "codefor" set BOOKFILE "/home/codefor" #upload spawn bash -c "scp *.zip $USER@$HOST:$BOOKFILE" expect { "*password*" {send "$PASS
" ;} } expect eof; |