Agilent Technologies ES Switch User Manual


 
6-28 LAN Interface Supplement
Controlling the Analyzer via the LAN
Controlling Multiple Analyzers using a Perl Script
Controlling Multiple Analyzers using a
Perl Script
The following Perl script demonstrates how you can control a network of
analyzers from your workstation.
The script downloads an IBASIC program to a group of analyzers. The
IBASIC program makes a measurement, and then signals the computer
that it needs service. (See the previous section, “IBASIC Communication
across the LAN” on page 6-24 to see how the IBASIC program
accomplishes this.)
The computer receives this signal, then queries the analyzer for
measurement data, and then tells the IBASIC program to continue.
NOTE This program is included on the Example Programs Disk shipped with
your analyzer as lan_serv.
#! /usr/bin/perl
#
# Perl script to listen on a port, and print received messages.
#
# This script is based on the "server" example in the
# book "Programming perl" by O'Reilley & Associates, Inc.
#
# require 'sys/socket.ph'; # Not needed on HP-UX
require 'ctime.pl'; # Allow use of ctime() to get date
# Get the port number from the command line (first arg).
# If no argument, default to a high-numbered port.
# Users can use ports above 1024 or so.
($port) = @ARGV;
$port = 8003 unless $port;
$AF_INET = 2; # from /usr/include/sys/socket.h
$SOCK_STREAM = 1; # from /usr/include/sys/socket.h
$PF_INET = $AF_INET; # from /usr/include/sys/socket.h
# Is this line noise? No, it's the pack format:
# S = unsigned short, n = short in network order
# a4 = 4 ascii characters, null padded,
# x8 = 8 null bytes (?)
$sockaddr = 'S n a4 x8';
chop($this_hostname = `hostname`);