Perl Net::Telnet 模块

发布于 2024-11-29 06:51:47 字数 97 浏览 2 评论 0原文

我正在尝试编写一个使用 Net::Telnet 代码的 perl 模块,但问题是提示符。我正在为其他用户编写应用程序,不确定他们可能有什么提示模式。有没有办法可以在运行时得到提示?

I am trying to write a perl module that uses the Net::Telnet code, but the problem is the prompt. I am writing the application for other user and not sure of what the prompt pattern they might have. Is there a way I can get the prompt at run time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

尤怨 2024-12-06 06:51:47

提示的默认值在几乎所有情况下都应该相当不错。

它查找以 #$% 后跟空格结尾的任何字符串。 # 由 root 使用,% 由 C 风格 shell 使用,$ 由 Bash 和 Kornshell 等 Bourne 风格 shell 使用。

如果您使用 Telnet,则您登录的帐户很可能会使用默认提示。

我更喜欢使用 Net::SSH ::Perl 并且不用担心用户提示。 Net::SSH::Perl 更安全,我可以用它传输文件或执行命令。

The default value for prompt should be pretty good in almost all circumstances.

It looks for any string that ends with either a # or a $ or a % followed by a space. The # is used by root, the % is used by C Style shells, and the $ is used by Bourne style shells like BASH and Kornshell.

If you're using Telnet, it's very likely you're logging into an account where the default prompt will work.

I prefer to use Net::SSH::Perl and not worry about user prompts. Net::SSH::Perl is more secure and I can transfer files, or execute commands with it.

残月升风 2024-12-06 06:51:47

由于远程端的 Telnet 会产生一个新的 shell 会话,(你是对的)它取决于用户的配置文件,提示符的外观如何。 shell 通常从 PS1 变量读取提示格式。所以你需要执行类似的操作:

echo $PS1
\u@\h:\w>

来阅读提示的样子。

As Telnet on remote side spawns a new shell-session, (you are right) it depends on user's profile how the prompt will look like. It is common for shells to read the prompt format from PS1 variable. So you need to execute something like:

echo $PS1
\u@\h:\w>

to read how the prompt looks like.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文