|
Question : Telnet - Windows XP - redirecting input/output problems
|
|
Hi. I'm having difficulty redirecting telnet output in windows.
My goal is to write VB.NET code to look at telnet output, and provide input based upon certain outputs.
Thus far, I'm able to provide input only... I just can't seem to redirect the output whether through cmd.exe -> telnet or directly to telnet.
Operating System: Windows XP
Anybody have any ideas?
Thanks!
|
Answer : Telnet - Windows XP - redirecting input/output problems
|
|
The set command should work for you :)
Welcome to Microsoft Telnet Client Escape Character is 'CTRL+]' Microsoft Telnet> ?
Commands may be abbreviated. Supported commands are: c - close close current connection d - display display operating parameters o - open hostname [port] connect to hostname (default port 23). q - quit exit telnet set - set set options (type 'set ?' for a list) sen - send send strings to server st - status print status information u - unset unset options (type 'unset ?' for a list) ?/h - help print help information
Microsoft Telnet> set ?
bsasdel Backspace will be sent as delete crlf New line mode - Causes return key to send CR & LF delasbs Delete will be sent as backspace escape x x is an escape charater to enter telnet client prompt localecho Turn on localecho. logfile x x is current client log file <--- Set logfile name logging Turn on logging <--- Set logging on mode x x is console or stream ntlm Turn on NTLM authentication. term x x is ansi, vt100, vt52, or vtnt Microsoft Telnet> http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/telnet_commands.mspx ------------------------------------------
This may work for you. Found a solution, ended up using pipes to redirect all streams. Posted by infamous Code: char psBuffer[128]; FILE *telnet; /* Run telnet so that it writes its output to a pipe. Open this * pipe with read text attribute so that we can read it * like a text file. */ if( (telnet = _popen( "cdrecord --help", "rt" )) == NULL ) exit( 1 ); /* Read pipe until end of file. End of file indicates that * telnet closed its standard out (probably meaning it * terminated). */ while( !feof( telnet ) ) { if( fgets( psBuffer, 128, telnet ) != NULL ) printf( psBuffer ); } /* Close pipe and print return value of telnet */ printf( "\nProcess returned %d\n", _pclose( telnet ) );
NOTE: I only used telnet for testing purposes, my real program created a blank file when I tried "cmd /c myProgram.exe > datafile.txt" with a system command or just "myProgram.exe > datafile.txt". The above was my solution. ----------------------------------------
Fyi-note - you may find this of interest -- WMIC. http://www.microsoft.com/technet/prodtechnol/windows2000serv/maintain/featusability/wmic.mspx
|
|
|
|