linux 脚本 等待时间长,linux – 期待脚本等待命令挂起

我有一个嵌入在bash脚本中的expect脚本:

#! /bin/bash

# this function runs a command like 'ssh' and provides the password

function with_password {

expect << END

spawn $2

expect *assword:*

send -- $1

interact

wait

END

}

# run "long_running_command" on the remote server

with_password my_password "ssh my_user@some-server long_running_command"

# rsync some data to the remote server

with_password my_password "rsync /some/dir my_user@some-server:/remote/dir"

# run some other random command

with_password my_password "ssh my_user@some-server some_other_command"

问题是有时脚本会在等待生成命令时挂起.如果我

将wait命令退出expect脚本,命令将继续在远程上运行

服务器,但bash脚本将继续,我无法知道它何时完成.

为什么我的期望脚本似乎随机挂起?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值