Hello.. I am having some problems with this sub... I am trying to take some
input box and send it to a file on a remote system.. Well, that works ok,
but I would like to rename the file when I am done, because a process polls
for the file.. Anyhow, I think my code is not releasing the handle on the
file after it write it, but I cannot for the life of me figure out how to do
so. Thanks for any help...

sub FTP_INBOX{
       # Variables
    my $widget = $OutputText->Subwidget("text");
    tie *STDOUT, ref $widget, $widget;
    $counter=1;
    my $loop_check= 0;
    my $ftp_site = "f1n27-sw";
    my $destination = "/prod/egate/data/journal";
    my $tFilename = "unknown";
    my $pFilename = "unknown";

# Start FTP: connect and login
   my $ftp = Net::FTP->new($ftp_site)
      or die "FTP: Couldn't connect: [EMAIL PROTECTED]";
   $ftp->login($uname_EGATE, $passwd_EGATE)
      or die "FTP: Couldn't login.";
# Specify a binary tranfer
   $ftp->binary()
      or die "FTP: Couldn't specify binary type.";
   $ftp->cwd("$destination") or
      die "\nBackup: No connection made, check username/password.\n\n";
# loop over all the records in the input box and send them over.
    if ($_[0] eq "TDS") {
       $tFilename = "tTDS.dat";
       $pFilename = "pTDS.dat";
       print qq(\n SENDING: TDS.dat);
   } else {
        $tFilename = "tSCM.dat";
        $pFilename = "pSCM.dat";
       print qq(\n SENDING: SCM.dat);
   }
     my  $ftpfile = $ftp->stor("$tFilename");
     #  $ftp->rnto("$pFilename");
     while ($loop_check == 0)
        {
        my $peg=$PegText->get($counter . '.0', $counter . '.0 lineend');
        my $pegSize=1024;
        $counter++;
         if ( $peg eq "")
               {$loop_check++}
               {
                  $ftpfile ->write( $peg , length $peg);
            };
          };
#$ftpfile->close();
 $ftpfile = $ftp->close();

$ftp->rename( $tFilename , $pFilename );

# Exit from the ftp session

$ftp->quit()
  or die "FTP: Couldn't quit.";
}



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to