Skip to content
CA Process Automation - 4.2.2
Documentation powered by DocOps

PerlScript Example: WinGetInfoPerl Script Operator

Last update December 11, 2014

The WinGetInfoPerl operator runs PerlScript on a Windows touchpoint. In the example process, PerlScript runs on a Windows touchpoint, although it could also be run on a UNIX touchpoint.

The script creates two indexed fields, HostList and OSList in the WinGetInfoPerl operator dataset. The script:
 

  • Reads the source file line-by-line.
  • Assigns host names ($host) to indexed values in sequential HostList fields. The numbering starts with 0 and finishes at one less than the number of rows that are read from the source file.
  • Assigns operating systems ($opsys) to indexed values in sequentially numbered OSList fields. The numbering starts with 0 and finishes at one less than the number of rows that are read from the source file.

The script populates the ARGV variable with the Parameters input area entries of the calling Run Script operator. The script assigns the number of rows it reads to the NumRowsRead operator dataset variable. The sleep 30 line pauses the operator for 30 seconds so the user can examine the folders and files created in the C2OSVD location. You would not include the sleep 30 line in a production script.

use strict;

my $filename = "";

print "  sample script to retrieve OS level data into variables within C2O\n\n";

my $numargs = @ARGV;

if ($numargs == 1) {

   $filename = shift @ARGV;

} else {

   print "enter path and filename to process:\n";

   chomp($filename = <STDIN>);

}

my $c2osvd = $ENV{'C2OSVD'};

mkdir $c2osvd;

mkdir $c2osvd . "/HostList";

mkdir $c2osvd . "/OSList";

open HANDLE, $filename or die "ERROR: unable to open $filename: $!\n";

my $counter = 0;

while (<HANDLE>) {

   my @fields = split;

   my $host = $fields[0];

   my $opsys = $fields[1];

   my $filename1 = $c2osvd . "/HostList/" . $counter;

   open HH, "> $filename1" or die "ERROR: unable to open $filename1: $!\n";

   print HH $host;

   close HH;

   my $filename2 = $c2osvd . "/OSList/" . $counter;

   open HH, "> $filename2" or die "ERROR: unable to open $filename2: $!\n";

   print HH $opsys;

   close HH;

   $counter++;

}

my $filename3 = $c2osvd . "/NumRowsRead";

open HH, "> $filename3" or die "ERROR: unable to open $filename3: $!\n";

print HH $counter;

close HH;

close HANDLE;

sleep 30;

Was this helpful?

Please log in to post comments.