WebTelnetSendCommand Function

Action

Sends a Telnet command to a Telnet connection.

Include file

WebAPI.bdh

Syntax

WebTelnetSendCommand(    in hWeb : number,
                         in iCmd : number,
                         in iOpt : number optional ) : boolean;

Return value

  • true if the operation was successful

  • false otherwise

Parameter Description
hWeb Valid handle to a Web connection created by WebTcpipConnect and set to Telnet mode using WebTcpipSetTelnetMode.
iCmd

Telnet command to be sent to server. May be:

  • TELNET_CMD_SE: End of sub-negotiation parameters.

  • TELNET_CMD_NOP: No operation.

  • TELNET_CMD_DataMark: The data stream portion of a synch. This should always be accompanied by an urgent TCP notification.

  • TELNET_CMD_Break: NVT character BRK.

  • TELNET_CMD_InterruptProcess: The function IP.

  • TELNET_CMD_AbortOutput: The function AO.

  • TELNET_CMD_AreYouThere: The function AYT.

  • TELNET_CMD_EraseCharacter: The function EC.

  • TELNET_CMD_EraseLine: The function EL.

  • TELNET_CMD_GoAhead: The GA signal.

  • TELNET_CMD_SB: Indicates that what follows is sub-negotiation of the indicated option.

  • TELNET_CMD_WILL: Indicates the desire to begin performing (or is confirmation that you are now performing) the indicated option.

  • TELNET_CMD_WONT: Indicates the refusal to perform (or continue performing) the indicated option.

  • TELNET_CMD_DO: Indicates the request that the other party perform (or confirmation that you are expecting the other party to perform) the indicated option.

  • TELNET_CMD_DONT: Indicates the demand that the other party stop performing (or confirmation that you are no longer expecting the other party to perform) the indicated option.

  • TELNET_CMD_EOF: End of file

  • TELNET_CMD_SUSP: Suspend current process

  • TELNET_CMD_ABORT: Abort process

  • TELNET_CMD_EOR: End of record (RFC 885)

iOpt

Optional Telnet command option (optional). Only valid for commands WILL/WONT/DO/DONT and SB.

For a complete list of telnet options, please refer to http://www.iana.org/assignments/telnet-options.

The following predefined constants are available, however (due to the nature of Telnet options) are not mandatory:

  • TELNET_OPT_TransmitBinary: Binary transmission [RFC856, RFC1576]

  • TELNET_OPT_Echo: Echo [RFC857, RFC1576]

  • TELNET_OPT_Reconnection: Reconnection [NIC50005]

  • TELNET_OPT_SuppressGoAhead: Suppress go ahead [RFC858, RFC1576]

  • TELNET_OPT_ApproxMsgSizeNegotiation: Approx message size negotiation [ETHERNET]

  • TELNET_OPT_Status: Status [RFC859, RFC1576]

  • TELNET_OPT_TimingMark: Timing mark [RFC860, RFC1576]

  • TELNET_OPT_RemoteContrTransAndEcho: Remote controlled trans and echo [RFC726]

  • TELNET_OPT_OutputLineWidth: Output line width [NIC50005]

  • TELNET_OPT_OutputPageSize: Output page size [NIC50005]

  • TELNET_OPT_OutputCRDisp: Output carriage-return disposition [RFC652]

  • TELNET_OPT_OutputHorTabStops: Output horizontal tab stops [RFC653]

  • TELNET_OPT_OutputHorTabDisp: Output horizontal tab disposition [RFC654]

  • TELNET_OPT_OutputFFDisp: Output form-feed disposition [RFC655]

  • TELNET_OPT_OutputVerTabStops: Output vertical tab stops [RFC656]

  • TELNET_OPT_OutputVerTabDisp: Output vertical tab disposition [RFC657]

  • TELNET_OPT_OutputLFDisp: Output line-feed disposition [RFC658]

  • TELNET_OPT_ExtendedASCII: Extended ASCII [RFC698]

  • TELNET_OPT_Logout: Logout [RFC727]

  • TELNET_OPT_ByteMacro: Byte macro [RFC735]

  • TELNET_OPT_DataEntryTerminal: Data entry terminal [RFC1043, RFC732]

  • TELNET_OPT_SupDup: SUPDUP [RFC736, RFC734]

  • TELNET_OPT_SupDupOutput: SUPDUP output [RFC749]

  • TELNET_OPT_SendLocation: Send location [RFC779]

  • TELNET_OPT_TerminalType: Terminal type [RFC1091, RFC930, RFC1576]

  • TELNET_OPT_EndOfRecord: End of record [RFC885, RFC1576]

  • TELNET_OPT_TacacsUserId: TACACS user identification [RFC927]

  • TELNET_OPT_OutputMarking: Output marking [RFC933]

  • TELNET_OPT_TerminalLocNr: Terminal location number [RFC946]

  • TELNET_OPT_3270Regime: Telnet 3270 regime [RFC1041, RFC1576]

  • TELNET_OPT_X3PAD: X.3 PAD [RFC1053]

  • TELNET_OPT_NegotiateWindowSize: Negotiate about window size [RFC1073]

  • TELNET_OPT_TerminalSpeed: Terminal speed [RFC1079]

  • TELNET_OPT_RemoteFlowControl: Remote flow control [RFC1372]

  • TELNET_OPT_LineMode: Line mode [RFC1184]

  • TELNET_OPT_XDisplayLocation: X display location [RFC1096]

  • TELNET_OPT_Environment: Environment option [RFC1408]

  • TELNET_OPT_Authentication: Authentication option [RFC2941]

  • TELNET_OPT_Encryption: Encryption option [RFC2946]

  • TELNET_OPT_NewEnvironment: New environment option [RFC1572]

  • TELNET_OPT_TN3270E: TN3270E [RFC1647]

  • TELNET_OPT_XAUTH: XAUTH [Earhart]

  • TELNET_OPT_CHARSET: CHARSET [RFC2066]

  • TELNET_OPT_RemoteSerialPort: Telnet remote serial port (RSP) [Barnes]

  • TELNET_OPT_ComPortControl: Com port control option [RFC2217]

  • TELNET_OPT_SuppressLocalEcho: Telnet suppress local echo [Atmar]

  • TELNET_OPT_StartTLS: Telnet start TLS [Boe]

  • TELNET_OPT_Kermit: KERMIT [RFC2840]

  • TELNET_OPT_SendUrl: SEND-URL [Croft]

  • TELNET_OPT_ForwardX: FORWARD_X [Altman]

  • TELNET_OPT_PragmaLogon: TELOPT PRAGMA LOGON [McGregory]

  • TELNET_OPT_SspiLogon: TELOPT SSPI LOGON [McGregory]

  • TELNET_OPT_PragmaHeartbeat: TELOPT PRAGMA HEARTBEAT [McGregory]

  • TELNET_OPT_EXOPL: Extended options list [RFC861]

Example

dcltrans
  transaction TInit
  begin
    StrSetHostCP(28591); // 28591 (ISO 8859-1 Latin I)
  end TInit;
  transaction   TMain
  var
    hWeb0     : number;
    sBuffer   : string;
    sBoundary : string;
    nOption   : number;
  begin
    WebTcpipConnect(hWeb0, "My.TelnetHost.IP", WEB_PORT_TELNET);
    WebTcpipSetTelnetMode(hWeb0, TERMINAL_TYPE_ANSI, 80, 24, true,
      TELNET_MODEOPT_SYNC);
    WebTcpipGetOptions(hWeb0, nOption);
    if nOption <> TELNET_MODEOPT_RFC_1576 then
      WebTcpipSetOptions(hWeb0, TELNET_MODEOPT_RFC_1576);
    end;
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TerminalType);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TerminalSpeed);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_XDisplayLocation);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_NewEnvironment);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_TerminalType);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_TerminalSpeed);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_XDisplayLocation);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_NewEnvironment);
    WebTelnetRecvSubNegotiation(hWeb0, TELNET_OPT_TerminalType);
    WebTelnetSendTerminalType(hWeb0, "vt100");
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_SuppressGoAhead);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_Echo);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_NegotiateWindowSize);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_Status);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_RemoteFlowControl);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_SuppressGoAhead);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_Echo);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_NegotiateWindowSize);
    WebTelnetSendSubNegotiation(hWeb0, TELNET_OPT_NegotiateWindowSize, "\h00500018");
    WebTelnetSendCommand(hWeb0, TELNET_CMD_DONT, TELNET_OPT_Status);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WONT, TELNET_OPT_RemoteFlowControl);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_Echo);
    WebTcpipGetPacketBoundary(hWeb0, sBoundary);    
    WebTcpipRecvPacketsUntilData(hWeb0, "login: ");
    WebTelnetTypeKeys(hWeb0, StrToHostCP("leo"), 359.3, TELNET_FLAG_CASE_SENSITIVE);
    WebTcpipSendBin(hWeb0, "\h0D00");
    WebTcpipRecvExact(hWeb0, NULL, 390);
    WebTcpipSetPacketBoundary(hWeb0, sBoundary);
    WebTcpipRecvUntilIdle(hWeb0, NULL, 5000);
    WebTcpipSendBin(hWeb0, "\h0D000D0A");
    WebTcpipRecvPackets(hWeb0, NULL, 3);
    WebTcpipSendBin(hWeb0, "\h0D00");
    WebTcpipSendPacket(hWeb0, StrToHostCP("8") + "\h0D00");
    WebTcpipRecvClose(hWeb0, NULL);
    WebTcpipShutdown(hWeb0);
  end TMain;