Running applications through Telnet

一世执手 提交于 2019-12-11 01:31:48

问题


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


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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.




回答6:


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.




回答7:


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.



来源:https://stackoverflow.com/questions/283728/running-applications-through-telnet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!