Related sites:
More related sites:

Naurtech Support Wiki

Navigation: Print | Search | Wiki Home | Back to www.naurtech.com

Support Topics

  • Home
  • Usage Videos
  • Scripting
  • Web Browser
  • Download & Setup
  • License Registration
  • Cold Boot Persistence
  • Barcode Scanner
  • Remapping keys
  • Sounds & Tones
  • Lockdown & Fullscreen
  • Misc. & Usage Tips
  • Tools & Utilities

Wiki Actions

  • View
  • Edit
  • Print
Naurtech Corporation Copyright. All rights reserved.

Dynamically change IP address of destination host and connect to it

This script will dynamically change the IP address of the destination host and connect to it. It retrieves the configured host IP address x.Y.z.W. It then changes the IP address to x.22.z.250 and saves it to the configuration. The portion of the IP address marked in red is updated. It then invokes a connect operation which connects the session using the updated IP address.

Note that several lines of the script are commented out. These show validation and debugging possibilities. Feel free to uncomment these and use as required in your scenario.

To download, right mouse click and select "Save Target As..." CustomConnect.js

/* Custom Connect Script */
// For example, a terminal IP address 134.23.225.20 connects to host 134.22.225.250

// USAGE: Assign a key to a separate script slot with the following contents
//        to connect session 1:
//          "CustomConnect(1);"

function CustomConnect(session)
{
    // Get device IP
    var ip = CETerm.GetProperty( "device.ipaddress" );

    // Split IP into separate parts
    var iparray = ip.split(".");

    // TODO: Add checking for valid IP address in your network
    //       For example:
    //     if (iparray[0] != 134)
    //     {
    //         OS.Alert("Invalid IP address of device.");
    //         return;
    //     }


    // Build host IP by changing values
    iparray[1] = 22;
    iparray[3] = 250;

    var hostip = iparray.join(".");

    // Set new host address
    CETerm.SetProperty( "session" + session + "connection.host", hostip );

    // DEBUG: Uncomment next line to check host IP
    //OS.Alert("hostip=" + hostip);

    // Switch to session
    CETerm.PostIDA( "IDA_SESSION_S" + session, session );

    // Connect session
    CETerm.PostIDA( "IDA_SESSION_CONNECT", session );
}

Here are the installation steps.

  1. Load the CustomConnect.js script into CETerm and mark it to "Load at Startup"
  2. Create a script to run the CustomConnect() function. This sample assumes you are going to connect session 1.
  3. Select an empty script slot (for example Script 2)
  4. Tap Edit and enter this text CustomConnect( 1 );
  5. Tap OK.

To bind Script 2 to a key to connect to your host, you can select any key of your choice which will trigger a session connect.

  1. Open Session->Configure->Options->Configure Keybars and Keys
  2. Select the Edit Keymap tab.
  3. IMPORTANT: Select the "Unconnected" map for this key. This key will be active and pressed only when the session is unconnected.
  4. Tap New and select the desired key.
  5. Select the script slot you used above (for example Script 2).
  6. Tap OK to close all dialogs.
The article is provided as a service to current and perspective Naurtech customers. Trademark references made to various companies and their products belong to the respective companies. All information is provided as is. For questions, please contact us at  support@naurtech.com.