- 论坛徽章:
- 0
|
本帖最后由 xiaopan3322 于 2010-12-10 15:21 编辑
回复 1# wild_li
你能用send去执行scp命令吗,给个例子,我用的是rsync:
从例子中你可以看到,我一开始也是用的是spawn,不过后来我发现不能传变量,所以我用了send:
- #!/usr/bin/expect --
- set timeout -1
- set label [lindex $argv 0]
- # login to nxnlte4 in ulm & setview
- #spawn ssh xiabao@nxnlte3.mu.emea.nsn-intra.net
- spawn ssh xiabao@nxnlte3
- expect {
- "(yes/no)?" {
- send "yes\r"
- }
- "Password" {
- send "123456\r"
- }
- }
- sleep 1
- #send "cleartool setview timo\r"
- send "cleartool setview ltecm_ulphy_1004\r"
- sleep 5
- # baseline location
- #send "cd /lte/lteTransfer/TO_PN\r"
- # transfer the package what you need, you should assign a label
- #spawn rsync -avz "$label".zip tdlteman@hzling05.china.nsn-net.net:/bts_gmps_hz/basics/SC/CPLANE/"$label"
- send "rsync -avz /lte/lteTransfer/TO_PN/$label* tdlteman@hzling05.china.nsn-net.net:/home/tdlteman/share/basics/downloads/\r"
- expect "total size"
- expect {
- "rsync error" {
- exit 1
- }
- }
- expect "nxnlte4"
- send "exit\r"
- expect "nxnlte4"
- send "exit\r"
- #send "exit\r"
- interact
复制代码 |
|