Hi folks,
I've created a log file in my code, and I print various strings to it as I
go through my program. The problem is that everything is showing up on one
line for each iteration of my main loop, even though I have newlines in the
string.
I'm getting:
The log starts here
Can't make test-sendCan't change to test-send directory.Finished
Transmission at
s0005rx
Can't make test-sendCan't change to test-send directory.Finished
Transmission at
s0008rx
What I'm after:
The log starts here
Can't make test-send
Can't change to test-send directory
Finished Transmission at s0005rx
Can't make test-send
Can't change to test-send directory.
Finished Transmission at s0008rx
My code is below. I'm looking for nifty timestamp idiom too, but I'll
settle for the newlines getting fixed.
TIA
Dave
-------------------begin code--------------------------------------
#!/usr/bin/perl
use strict;
use Net::FTP::File;
open (LOG,">>test-send.log");
print LOG "The log starts here\n";
my $host;
open(HOSTLIST, "hostlist.txt");
while (<HOSTLIST>) {
$host = $_;
chomp($host);
print "Contacting $host\n";
my $ftp=Net::FTP->new($host,Debug=>0, Timeout=>360) or print LOG "Can't
conn
ect to $host";
$ftp->login("mylogin", "mypasswd") or die "Can't login to $host";
$ftp->binary;
$ftp->cwd("/tmp") or print LOG "Can't change to /tmp";
$ftp->mkdir("test-send") or print LOG "Can't make test-send";
$ftp->cwd("/usr/meh/test-send") or print LOG "Can't change to test-send
d
irectory.";
##put the files in /tmp/test-send
$ftp->put("PRGUPDT.707.2C") or die "unable to send PRGUPDT";
$ftp->chmod("755", "PRGUPDT.707.2C") or die "unable to chmod";
$ftp->quit;
print LOG "Finished Transmission at $host\n";
}
close(LOG);
c