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:
/home/lanforge/scripts
How to Run Scripts
- Starting a script on Windows:
-
- Make sure that perl is in your PATH.
(See Inspecting DOS PATH)
- Open a CMD window (or a PowerShell window)
- and change directory to C:\Program Files (x86)\LANforge-Server\scripts
- 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:
- 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
$ ./lf_portmod.pl --help
#...help appears...
$ ./lf_portmod.pl --manager 192.168.100.1 --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 (192.168.100.2) and desire to run tests on resource 3 (192.168.100.3):
$ cd /home/lanforge/scripts
$ ./lf_portmod.pl --manager 192.168.100.1 --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: http://www.candelatech.com/private/downloads/r5.3.2/LANforgeServer-5.3.2_Linux-F21-x64.tar.gz.
For best results, use the scripts packaged with the version of LANforge to which your scripts will be connecting.
- Open a terminal on your desktop, cd to your Downloads folder
- use wget or curl to download the tar file:
wget "http://guest:guest@www.candelatech.com/private/downloads/r5.3.2/LANforgeServer-5.3.2_Linux-F21-x64.tar.gz"
- Create a scripts directory in your Documents folder:
$ cd ~/Documents/scripts
- Expand the tar file in your Downloads directory:
$ tar xf LANforgeServer*tar.gz
- 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
$ ./lf_portmod.pl --manager 192.168.100.1 --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.
- Download the Windows version of the LANforge Server installer using your browser:
http://www.candelatech.com/private/downloads/r5.3.2/LANforge-Server-5.3.2-Installer.exe.
Use username guest, password guest.
- 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.
- The installation scripts folder will be system-protected, so you want to copy the folder over to your
desktop Documents directory.
- Open a DOS terminal, either using Run→cmdEnter
or Run→powershellEnter
- 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 .\lf_portmod.pl --manager 192.168.100.1 --card 3 --show_port --port_name eth1 --quiet 1
- To capture output from a script, use the shell redirect operator: >. This example shows redirecting and
browsing the results with Notepad:
C:> perl .\lf_portmod.pl --manager 192.168.100.1 --card 3 --show_port --port_name eth1 --quiet 1 > results.txt
C:> notepad.exe results.txt