GFTelnet Class Documentation

Written in December 2003 by Gerd Feldkirch (mailto: gerd.feldkirch@t-online.de)

This class supplies methods for scripting Telnet-Sessions.
If a method fails the return value is -1, otherwise it is 0.


Constructor


GFTelnet()


Methods


close()

connect( String _HostName, int _Port )

print( String _String, int _Echo )

waitFor( String _String, int _Echo )

Sample Application

module Main;
function main() {
 GFTelnet gfTelnet; // create GFTelnet object
 if( gfTelnet.connect( "127.0.0.1", 23 ) < 0 ) return; // connect to server
 if( gfTelnet.waitFor( "user:", 1 ) ) < 0 ) return; // wait for username
 if( gfTelnet.print( "username", 1 ) < 0 ) return; // send user name
 if( gfTelnet.waitFor( "pass:" ) < 0 ) return; // wait for password
 if( gfTelnet.print( "password" ) < 0 ) return; // send password
 if( gfTelnet.waitFor( ">", 1 ) < 0 ) return; // wait for prompt
 if( gfTelnet.print( "ls", 1 ) < 0 ) return; // send command 'ls'
 if( gfTelnet.waitFor( ">", 1 ) < 0 ) return; // wait for prompt
 gfTelnet.close(); // quit session
}