Candela Technologies Logo
+1 360 380 1618 [PST, GMT -8]
Network Testing and Emulation Solutions

Introduction to CLI Scripts

Goal: You will be able to execute LANforge testing scripts from the command line from Windows, Linux, remote desktop or ssh connection.

Traffic emulation may be run unattended and automated using Perl scripts provided with the LANforge Server. These scripts can be run from within the LANforge server or outside the LANforge Server (on a Windows or other desktop). The output of the scripts should be redirected into a text file for you to process the results.

Where Do I Find Scripts?

On Windows

On most versions of windows, the LANforge Server installs scripts in

C:\Program Files (x86)\LANforge-Server\scripts

On Linux

In the home directory for user LANforge:


How to Run Scripts

Starting a script on Windows:
  1. Make sure that perl is in your PATH. (See Inspecting DOS PATH)
  2. Open a CMD window (or a PowerShell window)
  3. and change directory to C:\Program Files (x86)\LANforge-Server\scripts
  4. Type perl .\script_name.plENTER to run the script.
Generally, the script will tell you that it needs more switches.
Finding Help
Most scripts have a -h or --help switch that explain what switches they expect.
Script Conventions
In general, scripts will expect you to tell them a few things, regardless of the script:
  • The manager IP address to connect to:--mgr or --manager This often defaults to, but when connecting from outside the machine, please use the IP of the LANforge management port (often eth0).
  • The manager port to connect to:--port 4001 or --mgr_port 4001. This often defaults to 4001.
  • Which resource to direct the command to. The manager is always resource 1. Resource 2 would be your second LANforge server. --resource 2. Some scripts use the older term card: --card
  • If you need debugging output, turn off quiet mode: -q no or --quiet no. Some older scripts want you to turn quiet on explicitly: --quiet 1
  • To capture the output, use the > operator to redirect the text output into a text file.
  • Scripts are often executed from within a shell script (or batch file). Often the formatting of the commands includes '\' characters which indicate 'continue this command on the next line of input.' Here is an example of formatting a single script command on multipl lines:
     $ ./ \
       --manager \
       --card 3 \
  • Comments begin with '#'. They are lines ignored by the shell, and they are also comments in perl.
Running on local LANforge manager
You can use ssh, VNC or Rdesktop to connect from your desktop to your LANforge manager server. (When using VNC, assume display :1). From there, in a terminal, you will execute your script from the /home/lanforge/scripts directory as shown in the example below:
 $ cd /home/lanforge/scripts
 $  ./ --help appears...
 $ ./ --manager --card 1 --show_port
# ... displays port info
Running on local LANforge resource
If you connect to a LANforge resource and want to run a script, you must direct the script at the LANforge manager server and specify the resource you are interested in. For example, you might be on resource 2 ( and desire to run tests on resource 3 (
 $ cd /home/lanforge/scripts
 $  ./ --manager --card 3 --show_port
# ... displays port info
Running on a Linux Desktop to a Remote LANforge
A more detailed set of steps follows. When running LANforge CLI scripts on a Linux desktop, you normally want to download and un-zip a copy of the LANforge-Server install file found on the Candela Technologies downloads page. Use a link similar to: For best results, use the scripts packaged with the version of LANforge to which your scripts will be connecting.
  1. Open a terminal on your desktop, cd to your Downloads folder
  2. use wget or curl to download the tar file:
     wget ""
  3. Create a scripts directory in your Documents folder:
     $ cd ~/Documents/scripts
  4. Expand the tar file in your Downloads directory:
     $ tar xf LANforgeServer*tar.gz
  5. Copy the scripts file into your Documents folder:
     $ cp -r LANforgeServer-5.3.2/scripts/. ~/Documents/scripts/

To use your scripts, in your terminal, change directories to ~/Documents/scripts and they will operate similar to the above examples.

 $ cd ~/Documents/scripts
 $ ./ --manager --card 3 --show_port

Running on a Windows Desktop to a Remote LANforge
The process for running CLI scripts on a Windows desktop is roughly similar, but involves running the Windows LANforge Server installer. This process does not require a Windows license as we will not be running the windows LANforge server. Perl is required to run Windows scripts. Start by installing that. You can use the perl that comes with the Cygwin project or if you just want perl, install the ActiveState ActivePerl package. ActivePerl should install update your environment %PATH% variable. If it does not immediately, you might need to log out and log back in.
  1. Download the Windows version of the LANforge Server installer using your browser: Use username guest, password guest.
  2. In your Downloads folder, double click and install the LANforge-Server-Installer.exe. Do not configure it, do not run LANforgeServer. You will not need to be running the LANforge GUI to do this install.
  3. The installation scripts folder will be system-protected, so you want to copy the folder over to your desktop Documents directory.
  4. Open a DOS terminal, either using Run→cmdEnter or Run→powershellEnter
  5. Change to the new copy of the scripts directory, and then you can run scripts by giving them to perl:
     C:> cd C:\Users\bob\Documents\scripts
     C:> perl .\ --manager --card 3 --show_port --port_name eth1 --quiet 1
  6. To capture output from a script, use the shell redirect operator: >. This example shows redirecting and browsing the results with Notepad:
     C:> perl .\ --manager --card 3 --show_port --port_name eth1 --quiet 1 > results.txt
     C:> notepad.exe results.txt

Candela  Technologies, 2417 Main Street, Suite 201, Ferndale, WA 98248, USA | | +1.360.380.1618
Google+ | Facebook | LinkedIn | Blog