通过 Telnet 运行应用程序
我需要创建一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您是否尝试过:
但是,如果远程 telnet 服务器需要用户名和密码,则这将不起作用。
Have you tried:
this won't work if the remote telnet server requires a username and password, though.
根据您的路径,我假设您正在 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.
以您想要的方式使用 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.
您尝试过以下方法吗?
其中 someScipt 有您的命令,例如
C:\Application\app.exe -a -b -c
您是否看过 Windows 远程 Shell 守护进程? 这可能比 telnet 好很多。
Have you tried the following?
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.
expect尝试一下
从网页
give expect a try
from the webpage:
您的 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.您可以考虑使用 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.