rsh 与 Perl 的 Expect.pm 相比有何优势?
我有一个 Perl Expect.pm 脚本,它可以执行一些中等复杂的操作,例如打包应用程序、部署应用程序、检查多个远程 UNIX 主机上的日志等。
我的前任使用 rsh 编写了类似的脚本。
两者之间有更好的方法吗? 或者我应该使用不同的东西?
我猜有人会提出 SSH; 它基本上是 rsh 的替代品,对吧? 不幸的是,SSH 目前不适合我。
我应该补充的另一件事是,登录后我需要能够 SUDO 到特定用户以在远程主机上执行大部分操作。
I have a Perl Expect.pm script that does some moderately complex stuff like packaging applications, deploying the application, checking for logs, etc. on multiple remote unix hosts.
My predecessor had written similar scripts using rsh.
Is there a better approach between the two? Or should I use something all together different?
I am guessing somebody will bring up SSH; it's basically replacement for rsh, right? Unfortunately, however SSH is not an option for me right now.
Another thing I should add is that after logging in I need to be able to SUDO to a particular user to do most of the actions on the remote hosts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为了解决这一特定问题:使用
rsh
(或ssh
),您可以指定在远程会话中成为哪个用户:无需使用
sudo 在这种情况下。 由于安全问题,现在肯定是研究
ssh
的时候了。 语法是相同的,但是ssh
也允许稍微不同的(我想说更好)语法:我发现
expect
太挑剔了,但我的经验是并不重要。To address this one particular point: using
rsh
(orssh
) you can specify which user to become in the remote session:There's no need to use
sudo
in this case. Now would definitely be the time to look intossh
due to security issues. The syntax is the same, butssh
also allows a slightly different (and I'd say better) syntax:I found
expect
to be too finicky, but my experience with it is not substantial.他们做不同的事情。 Expect 是一种编写脚本的方法,否则需要手动响应。 rsh——远程 shell,不是受限 shell,不幸的名称冲突——允许您在另一个系统上远程运行命令。
也就是说,使用 rsh 执行远程命令、运行 sudo 等的安全漏洞和其他缺点是巨大的。
They do different things. Expect is a way to script what would otherwise be manual responses. rsh -- remote shell, not restricted shell, an unfortunate name clash -- allows you to run commands remotely on another system.
That said, the security holes and other disadvantages of using rsh to do remote commands, run sudo, etc, are immense.
我可以看到多种执行此操作的方法:
优点
优点
考虑到所有因素,这是最轻微的缺点,因为您可以简单地执行类似的操作,
当然,您可以添加一些错误处理(打开失败,如果 /tmp/myscript 存在怎么办等),但这就是想法。
I can see multiple ways of doing this:
All things considered, this is the most minor con as you could simply do something like
Of course, you'd add in some error handling (failed open, what if /tmp/myscript exists, etc.), but that's the idea.
如果通过
expect
在rsh
和telnet
之间进行选择,我会选择rsh
。Expect
脚本很脆弱。 破坏一个只需有人更改远程计算机上的PS1
值即可。 使用rsh
还可以为您最终进入 90 年代并开始使用ssh
做好准备(因为您通常只需将rcp
更改为 < code>scp 和rsh
到ssh
并且一切仍然有效)。Given a choice between
rsh
andtelnet
viaexpect
, I would chosersh
.Expect
scripts are fragile. All it takes to break one is someone changing the value ofPS1
on the remote machine. Usingrsh
also prepares you for the day you will finally enter the '90s and start usingssh
(since you can mostly just changercp
toscp
andrsh
tossh
and everything still works).