本文介绍了使用Expect脚本自动处理多个文件的SCP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我看到了很多关于此的文章,也许我只是没有看到正确的文章.

So I have seen multiple posts on this and maybe I just haven't seen the right one.

我正在使用Expect脚本将多个文件从我的区域设置发送到远程站点.我不想为无密码登录设置密钥,因为那样服务器就不会被炸毁并且无法承担更多的工作,是的,我可以自动创建密钥,而我宁愿不这样做.所以我希望能够使用*,但是每次使用*都会告诉我.我要使用*而不是全名的原因是因为版本号会不断变化,并且我不想每次都手动更改脚本.

I am using an expect script to scp multiple files from my locale to a remote. I dont want to set up keys for passwordless logins, because then the servers cant be blown away and stood up with out more work, yes I could automate the key creation, I would just rather not. So I want to be able to use the * but every time I use the * it tells me. The reason I want to use * instead of a full name is because the version number will keep changing and I dont want to go manually change the script every time.

/path/{Install.sh,programWithVerionAfter*\}: No such file or directory

Killed by signal 1.

我希望这是一个简单的解决方法.我要做的就是将这些文件保存为scp,这样我就可以通过单击一个按钮来自动执行安装过程.预先感谢您的帮助

I am hoping that this is an easy fix or workaround. All I would like to do is scp these files so I can automate an install process with the click of a button. Thankyou in advance for any help

#!/usr/bin/expect -f

spawn scp /path/\{Install.sh,programWithVerionAfter*\} "root@IP:/tmp/.
expect {
   -re ".*es.*o.*" {
   exp_send "yes\r"
   exp_continue
  }
  -re ".*sword.*" {
    exp_send "Password\r"
  }
}
interact

推荐答案

我通过更多的Google搜索发现了自己想要的东西.谢谢您的帮助,希望对您有所帮助

I found what I wanted with much more googleing. Thankyou for your help, hope this helps others

http://www.linuxquestions.org/questions/linux-general-1/scp-with-wildcard-in-expect-834813/

#!/usr/bin/expect -f

spawn bash -c "scp /path/* root@IP:/tmp/"
expect {
  -re ".*es.*o.*" {
    exp_send "yes\r"
    exp_continue
  }
  -re ".*sword.*" {
    exp_send "Password\r"
  }
}
interact

这篇关于使用Expect脚本自动处理多个文件的SCP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 18:58
查看更多