2013-08-28 89 views
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錯誤。

那麼誰能幫我弄清楚如何通過期望來運行腳本?非常感謝。

回答

相關問題