问题描述
我有一个在 Windows 机器上运行的 Perl 脚本.我需要这个脚本来打开到远程 Unix 机器的 ssh 会话,并且能够在该 Unix 机器上执行某些命令并能够从这些命令返回输出.
I have a Perl script running on a Windows machine. I need this script to open a ssh session to a remote Unix machine, and to be able to execute certain commands on that Unix machine and to be able to get the output returned from these commands.
这些命令是在脚本运行时生成的,其中有很多是在不同时间执行的.
These commands are generated during the run-time of the script, and there are many of them executed at different times.
我该怎么做?
推荐答案
方法 1:使用 CYGWIN:http://perlwin32ssh.blogspot.com/2007/07/test_4418.html
Approach 1: Use CYGWIN: http://perlwin32ssh.blogspot.com/2007/07/test_4418.html
方法 2:使用 Net::SSH::W32Perl
模块.
Approach 2: Use Net::SSH::W32Perl
module.
这是一个讨论如何安装它的线程:http://code.activestate.com/lists/perl-win32-users/29180/(好像需要下载自定义版本的模块)
This is one thread discussing how to install it: http://code.activestate.com/lists/perl-win32-users/29180/ (It seems to require downloading custom version of the module)
此线程应该有助于解决 ssh 计算所需的数学库依赖所引起的问题:http://www.issociate.de/board/post/494356/I%27m_trying_to_install_%27Net::SSH::Perl%27_on_a_Windows_Box..html
This thread should help with the problems arising from dependencies on math libraries needed for ssh calculations: http://www.issociate.de/board/post/494356/I%27m_trying_to_install_%27Net::SSH::Perl%27_on_a_Windows_Box..html
警告:我从来没有安装过这个,以上只是对谷歌结果的一些分析.
Caveat emptor: I never installed this, the above is just result of some analysis of google results.
这篇关于如何打开 ssh 会话并从 Perl 脚本执行命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!