Signiant Support

Sample filename mapping command Print


The following is a example filename mapping command. This will place incoming files into a subdirectory based on the source agent's hostname.

     #!dds_perl
     my $FILENAME;
     my $FILEHOST;
     my $FILESIZE;
     my $FILETYPE;
     my $FILEDATE;
     my $FILETIME;
     while (<STDIN>)
     {
          #
          # Format of expected input line (in implicit &#39;$_&#39; from &lt;STDIN&gt;) is:
          #
          # "Filename" Agent_Host File_Size File_Type File_Date File_Time
          #
          m/\"(.+)?\"\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)/;
          #" <;-- Workaround for syntax-highlighting glitch caused by previous regex
          $FILENAME = $1;
          $FILEHOST = $2;
          $FILESIZE = $3;
          $FILETYPE = $4;
          $FILEDATE = $5;
          $FILETIME = $6;

          #Get the file name
          $FILENAME =~ s|\\|/|g;
          $FILENAME = basename($FILENAME);

          $FILENAME = "$FILEHOST/$FILENAME";
          print "$FILENAME\n";
     }
     exit 0;