?
Solved

telnet from ASP to send a simple command?

Posted on 2004-10-24
19
Medium Priority
?
2,110 Views
Last Modified: 2007-12-19
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
Comment
Question by:thedogeater
  • 7
  • 6
  • 3
16 Comments
 

Author Comment

by:thedogeater
ID: 12394357
I should say as well this is VBScript not .NET ASP
0
 
LVL 2

Expert Comment

by:larellnielsen
ID: 12396864
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
 
LVL 14

Expert Comment

by:huji
ID: 12398087
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:thedogeater
ID: 12405145
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
 
LVL 2

Expert Comment

by:larellnielsen
ID: 12407394
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
 
LVL 14

Expert Comment

by:huji
ID: 12407817
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
 
LVL 2

Expert Comment

by:larellnielsen
ID: 12421732
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
 
LVL 14

Expert Comment

by:huji
ID: 12422963
Very correct, LaRell.
Please send anything here, thedogeater.
Huji
0
 

Author Comment

by:thedogeater
ID: 12439698
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
 
LVL 14

Expert Comment

by:huji
ID: 12442629
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
 

Author Comment

by:thedogeater
ID: 12453541
creating the batch script is a biger problem for me now.
0
 
LVL 14

Expert Comment

by:huji
ID: 12457824
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
 

Author Comment

by:thedogeater
ID: 12465930
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
 
LVL 14

Expert Comment

by:huji
ID: 12466335
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
 

Author Comment

by:thedogeater
ID: 12525004
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
 
LVL 14

Accepted Solution

by:
huji earned 800 total points
ID: 12525379
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Integration Management Part 2
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

579 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question