Perl Script for sending files to Summon FTP

From Summon Community Wiki

Jump to: navigation, search

This Perl script can be used to send a file named "marcfile.out" to the Summon FTP server. The script will automatically rename the file to match Summon's naming conventions. This script can be set as a cron job along with your ILS export process to enable you to send your daily catalog records to Summon on a daily basis.

Be sure to set your username and password for the FTP account. You can also change the name of the file if you do not want to use the filename "marcfile.out"

use Net::FTP;
use Time::Local;

########## Change Here ############
$summonLogin = "XXX-catalog";
$summonPassword = "XXX";
$marcfile = "marcfile.out";
###################################

$summon_host = "ftp.summon.serialssolutions.com";

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$mon += 1;
$remote_name = "updates/$summonLogin-$year-$mon-$mday-$hour-$min-$sec.mrc";

$success = 0;

my $ftp = Net::FTP->new($summon_host, Passive => 1, Timeout => 5);
if ($ftp ne "")
{
  $success = $ftp->login($summonLogin, $summonPassword);
  if ($success == 1)
  {
      $pfile = $ftp->put($marcfile, $remote_name);
      if ($pfile ne "")
      {
        $success = $success + 1;
        $pfile = "";
      }
      $success = $ftp->quit();
      $success += 1;
  }
}
Personal tools
Navigation