• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2154
  • Last Modified:

telnet from ASP to send a simple command?

Is there any way in a ASP I can create a telnet session wait for a prompt to return (or perhaps just wait for a few seconds) and then send a command? I don't need to send any login information or the like just a command which is an ordinary text string.
0
thedogeater
Asked:
thedogeater
  • 7
  • 6
  • 3
1 Solution
 
thedogeaterAuthor Commented:
I should say as well this is VBScript not .NET ASP
0
 
larellnielsenCommented:
You will not be able to interact directly but you could create a DLL to do the heavy lifting and call that from ASP.

LaRell
0
 
hujiCommented:
Yes there probably is. If you can do something from command prompt, then you can do it from within ASP using a speical feature named Wscript Shell.
An example is here:
You can type "nslookup -type=mx www.yahoo.com" to find the IP addresses of Yahoo mail servers. What if you want to do it from within asp? ASP by itself does not have a utility to perform a Name Server Lookup, so... this article shows you how it is done:
http://www.asp101.com/articles/hojjat/mxlookup/default.asp
Conclusion: May be we can manage it to perform a telnet connection (even) this way. I need your commands (which you can run from command prompt to work with that remote server) and will try to write a code (if I can) to do it from within ASP.
Wish I can help
Huji
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
thedogeaterAuthor Commented:
The commands are simple in each case I need to only send one pice of text. I each case I just wish to send commands to certain IPs so I click on button 1 and it telnet to IP A and sends 'abc' click on button 2 and it sends '123' to IP B
0
 
larellnielsenCommented:
I would caution you against do something like this. By utilizing the WSH you are going to have to expose areas that should be secured. Although it may be nice to do these type of function straight from ASP, always err on the side of percaution.

LaRell
0
 
hujiCommented:
All right.
It seems to be easy. Please send me a line of that command, and I'll try to manage it for you.
And larellnielsen, told some important point sooner than I would do! This is correct. See, when you are connecting to another computer with WScript Shell, or with XMLHTTP (the second one is something like, ASP opens a web browser, goes to a web site, and then stores the HTML passed to him from that web site, to you, so that you can use it; You may have noticed XMLHTTP in that ASP101 article too), you must accept the risk that, you may be at risk. But the amount of risk is just no more than when you connect to the computers with telnet yourself. ASP just does what you do, and the risk is just the same.
Waiting for your one line command.
Huji
0
 
larellnielsenCommented:
Actually I was talking more towards exposing WSH within ASP. XMLHTTP is fine because it works more like a COM object than WSH. WSH is integrated into your OS :o( so it requires that you lower your security so that you can access it.

LaRell
0
 
hujiCommented:
Very correct, LaRell.
Please send anything here, thedogeater.
Huji
0
 
thedogeaterAuthor Commented:
Thanks it does not help me much however. I would need to see how some code to do this would work. Perhaps even if I could have a batch script to the telneting and subsequent sending of the command, then it is simple to call this from ASP no?
Security is not a concern, as this is available only on an trusted internal network.
0
 
hujiCommented:
Yes it is possible to be called from ASP! That's what I say. From within ASP you can call the batch file! This is the point I'm trying to make you catch.
Please send me a sample batch file. And I'll send you the ASP code. Let's give it try, huh?
Waiting for your action
Wish I can help,
Huji
0
 
thedogeaterAuthor Commented:
creating the batch script is a biger problem for me now.
0
 
hujiCommented:
All right, we may manage it too! Just answer to this question:
How do you cannot to those telnet remotes now, by typing some things in Comand Prmopt? Starting with:
telnet IP_ADDRESS
and so on?
If yes, just type all of those, here in the post box, and send them to me!
Huji
0
 
thedogeaterAuthor Commented:
Indeed I do I telnet to say 10.0.0.2 wait for the prompt and type 'Command1' or 'Command2' for example. I dont know how I can automate the whole thing.
0
 
hujiCommented:
is it something like this:
You first go to command prompt. Then you type:
telnet 10.0.0.2
Then you hit enter. Then you type command1. Again enter. Is it?
Then try this:

telnet 10.0.0.2
command1
...

now save it in a file in notepad. Then change the extension of the file from TXT to BAT and double click on it. It will automatically do the stuff. If it worker, then let's do it from ASP.
Waiting for your commnet,
Huji
0
 
thedogeaterAuthor Commented:
Hi Huji,

Thanks for you help but your script does not work the telnet command does not return untill it has finshed so can not take the input form the line bleow....
0
 
hujiCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 7
  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now