通过 Telnet 运行应用程序

发布于 2024-07-09 06:35:23 字数 337 浏览 6 评论 0原文

我需要创建一个 BAT 文件来通过 telnet 运行应用程序,但据我所知,在 DOS 上无法执行此操作。 Telnet 不允许在连接的瞬间向远程计算机发送任何命令,并且 BAT 文件中的每个后续命令只有在 telnet 停止后才会执行。 这段假设的代码说明了我想要做的事情:

telnet 100.99.98.1 "C:\Application\app.exe -a -b -c"

这将使用三个参数在计算机 100.99.98.1 上运行 app.exe。 尽管我努力了,但没有任何效果。 有没有办法做到这一点?

谢谢,

佩德林·巴蒂斯塔

I need to create a BAT file to run an application through telnet, but as far as I know there is no way to do this on DOS. Telnet does not allow any command to be sent to the remote machine at the very instant of the connection, and each subsequent command in the BAT file would only be executed after telnet stops. This hypothetical piece of code illustrates what I want to do:

telnet 100.99.98.1 "C:\Application\app.exe -a -b -c"

And that would run the app.exe on the machine 100.99.98.1 with three parameters. Despite my efforts, nothing worked. Is there a way to do that?

Tks,

Pedrin Batista

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

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

发布评论

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

评论(7

春风十里 2024-07-16 06:35:23

您是否尝试过:

echo "c:\application\app.exe -a -b -c" | telnet 100.99.98.1

但是,如果远程 telnet 服务器需要用户名和密码,则这将不起作用。

Have you tried:

echo "c:\application\app.exe -a -b -c" | telnet 100.99.98.1

this won't work if the remote telnet server requires a username and password, though.

沉默的熊 2024-07-16 06:35:23

根据您的路径,我假设您正在 Windows 平台上工作。 我建议您查看 Microsoft/SysInternals 的 PsExec ,它允许您在远程计算机上执行命令。

PsExec 是优秀的免费 PsTools 来自 Mark Russinovich 的软件包。 SysInternals 最近被 Microsoft 收购,但这些工具仍然免费。

然而,这在互联网上不起作用。 它使用 Windows 网络端口 445,并且只能在本地网络上使用。 如果您需要,我建议使用 SSH。

Due to your paths I'm assuming you are working on a windows platform. I'd suggest looking at PsExec from Microsoft/SysInternals which allows you to execute a command on a remote machine.

PsExec is part of the excellent free PsTools package from Mark Russinovich. SysInternals was recently purchased by Microsoft, but the tools remain free.

This does not, however, work over the internet. It uses windows networking port 445 and should only be used on local networks. If you need that I'd suggest using SSH.

逆光下的微笑 2024-07-16 06:35:23

以您想要的方式使用 telnet 恕我直言是不可能的。

您可以保护 shell (ssh),但 ssh 服务器必须在远程计算机上运行(在您的情况下为 100.99.98.1)。

编辑:

请参阅 http://sshwindows.sourceforge.net/ 了解 ssh 客户端和服务器(基于 cygwin ) 对于 Windows。

Using telnet in the way you want to is imho not possible.

You could you secure shell (ssh), but a ssh server has to run on the remote machine (100.99.98.1 in you case).

EDIT:

See http://sshwindows.sourceforge.net/ for a ssh client and server (based on cygwin) for Windows.

酒解孤独 2024-07-16 06:35:23

您尝试过以下方法吗?

telnet 100.99.98.1 <someScript

其中 someScipt 有您的命令,例如 C:\Application\app.exe -a -b -c

您是否看过 Windows 远程 Shell 守护进程? 这可能比 telnet 好很多。

Have you tried the following?

telnet 100.99.98.1 <someScript

Where someScipt has your command, e.g., C:\Application\app.exe -a -b -c

Have you looked at a Remote Shell daemon for windows? This is probably a lot better than telnet.

〗斷ホ乔殘χμё〖 2024-07-16 06:35:23

expect尝试一下

从网页

Expect 是一个自动化工具
交互式应用程序,例如
telnet、ftp、passwd、fsck、rlogin、
小费等。Expect 确实做到了这一点
琐碎的事情。 期待也有用
用于测试这些相同的应用程序。

give expect a try

from the webpage:

Expect is a tool for automating
interactive applications such as
telnet, ftp, passwd, fsck, rlogin,
tip, etc. Expect really makes this
stuff trivial. Expect is also useful
for testing these same applications.

被翻牌 2024-07-16 06:35:23

您的 telnet 应用程序是否需要在命令窗口中运行,或者您只需要从命令行启动它? 如果您想“启动后就忘记”,您可以考虑使用可编写脚本的终端程序,例如免费的 TeraTerm。 您可以使用 start 命令从命令行启动它,并让它在后台执行脚本。

Does your telnet app need to run in a command window, or do you only need to start it from the command line? If you want to "launch and forget," you might consider a scriptable terminal program such as the free TeraTerm. You can launch it from the command line with the start command and let it execute a script in the background.

风吹过旳痕迹 2024-07-16 06:35:23

您可以考虑使用 Cygwin (它提供了在 Windows 上运行的类似 Linux/Unix 的命令行环境) 。 Cygwin 提供了多种标准工具,包括 shell 脚本。

You might consider using Cygwin (which provides a Linux-/Unix-like command-line environment running on Windows). A wide range of standard tools, including shell scripting, is available as part of Cygwin.

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