InterviewSolution
| 1. |
Solve : login to telnet from batch script? |
|
Answer» I was able to set up a batch file to open a telnet session, but I still have to type in my username and password for the session to actually start. Is there any way to set up the batch file to automatically enter my username and password? Hello friend Try using some Telnet switches:Like a phoenix rising from the ashes, old posts spring forth to haunt us. You do realize this post is over 2 years old, right? You may need a working knowledge of how telnet prompts for parameters. Try combining the two responses above: echo password | telnet -l username IPaddress Be aware that putting unencrypted passwords into scripts/batch files is a security breach. Many programs will choke on the pipe; let's hope MICROSOFT followed their own standards. Good luck. Thanks for the reply.. I'm not too sure where this comes in... I have created a ".BAT" file inside it has this commands ---------------------------------------- c:\windows\system32\telnet.exe ---------------------------------------- this will open the telnet. Where do I go from here? I would like to login the username and password using the BAT file. is this possible? Did you run what was posted? echo password | telnet -l username IPaddress What were the results? Can you post the console output. If telnet cannot accept input from the pipe, it may be possible to redirect input from a file, but it will be necessary to see the sequence telnet requests the input. Of course telnet may only take the password from the keyboard in which case you will be SOL. Let us know. If the telnet userid and password are the same ones you use for Windows, try using the -a switch: Code: [Select]telnet -a IPaddress alternatively you can use other languages such as Perl that has telnet modules to do this task. eg Code: [Select] use Net::Telnet (); $t = new Net::Telnet (Timeout => 10, Prompt => '/bash\$ $/'); $t->open("hostname"); $t->login($username, $passwd); @lines = $t->cmd("who"); print @lines; more information here if you are interested.Yes. It is possible with help of another executable called telnetd.exe. I have developed this executable to automate telnetd.exe(http://myresearchdev.blogspot.sg/) session using windows batch file. Usage telnetd.exe script.txt scripts.txt -> for the telnet commands After the execution of the batch file you can seelogs from telnetlog.txt. This telnetlog.txt will help you to troubleshoot the commands and responses. |
|