0
我的本地机器上有一个Perl脚本,我想在远程服务器上运行它。下面的命令工作正常:通过期望在远程服务器上运行本地Perl脚本
ssh [email protected] "perl - --arg1 arg1 --arg2 arg2" < /path/to/local/script.pl
事情是,一个提示出现问我的密码,我不想这样。
我看了看周围净,发现3级的解决方案:
- 使用公钥/私钥认证 - >也不行于我而言
- 使用sshpass - >不要在我公司的“官方”回购因此不能安装它
- 使用expect
我跟着这个页面创建我期待的脚本(我是新来的期待):How to use bash/expect to check if an SSH login works,我拿着剧本从正确的答案,和r将3条第一行用#!/usr/bin/expect -f
代替以获得期望脚本。
然后我跑
./ssh.exp user password ipaddress "perl - --arg1 arg1 --arg2 arg2" < /path/to/local/script.pl
而且我有一个超时错误。这是因为如果我跑./ssh.exp user password ipaddress "perl"
我也试图把引号像
./ssh.exp user password ipaddress '"perl - --arg1 arg1 --arg2 arg2" < /path/to/local/script.pl'
但我有一个/path/to/local/script.pl not found
错误。
那么谁能帮我弄清楚如何通过期望来运行脚本?非常感谢。