使用 Telnet 或带有 Perl 的 SSH 从本地机器在远程机器上运行 perl 脚本 [英] Run a perl script on remote machine from local machine using Telnet or SSH with Perl

查看:40
本文介绍了使用 Telnet 或带有 Perl 的 SSH 从本地机器在远程机器上运行 perl 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 telnet 或 ssh 在远程机器上运行 Perl 脚本.脚本在我的本地主机上.如何做到这一点.任何人都可以帮我解决这个问题吗?

I want to run a Perl script in a remote machine using telnet or ssh. The script is on my local host.how can do this. Can anyone please help me on this?

推荐答案

如果你出于某种原因不想将脚本复制到远程主机然后运行它,你可以通过 stdin 将脚本发送到 Perl 解释器.如果 perl 没有在命令行上获取脚本的脚本名称,它会尝试在 stdin 上读取脚本.所以这会起作用:

If you for some reason don't want to copy the script to the remote host and then run it, you can send the script to the Perl interpreter over stdin. If perl doesn't get either a script name of a script on the command line it tries to read the script on stdin. So this would work:

ssh user@remote perl < my_script.pl

当然,这要求远程主机上已经安装了所有必需的模块.如果您的脚本只有纯 perl 依赖项,您可以使用 App::FatPacker<解决此限制/a> 使您的脚本(更多)自包含.

Of course this requires that all necessary modules are already installed on the remote host. If you script only have pure perl dependencies you can work around this restriction by using App::FatPacker to make your script (more) self contained.

但如果这是一项重复性任务,我建议您将脚本正确部署到远程主机.

But if this is an recurring task I would recommend getting the script deployed correctly to your remote host.

这篇关于使用 Telnet 或带有 Perl 的 SSH 从本地机器在远程机器上运行 perl 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆