I would implement the ftp transfer using a "native" ftp module (there are several) because running an external process and trying to parse the output always invites problems...

  --david

On 10/03/13 11:31, Jesse Becker wrote:
One quick thought:  it could be a terminal problem (or lack
thereof...).  Try running lftp via system(), but redirecting STDOUT to
a file as part of the call.  Then open the STDOUT file, parse it for
/Total 4 files transferred/, and proceed as before.

On Thu, Oct 3, 2013 at 12:23 PM, Ski Kacoroski <[email protected]> wrote:
Hi,

I have a simple perl script that creates some csv files and uploads them to
a vendor.   The problem code is:

sub UploadCSV {
   my $results = `/usr/bin/lftp -e "mput /var/spool/discoveryed/*.csv;bye" -u
ZZZZZZZZ,'YYYYY' transfer.discoveryeducation.com 2>&1`;
   print "ftp return: $results\n";
   if ( $results =~ /Total 4 files transferred/) {
     print "Discovery Education Upload Ok\n\n$results";
     `rm /var/spool/discoveryed/old/*`;
     `mv /var/spool/discoveryed/*roster*.csv
/var/spool/discoveryed/roster.prev`;
     `mv /var/spool/discoveryed/*.csv /var/spool/discoveryed/old`;
   } else {
     print "Discovery Education Upload Failed\n\n$results";
   }
}

My output from the cron job is:

ftp return:
Discovery Education Upload Failed

However in reality, the upload was successful (I can see the files on the
vendors site.  When I run it from the command link the $results are:

webapp:/opt/ski# ./DiscoveryEducation.pl
ftp return: 7452635 bytes transferred in 16 seconds (449.3K/s)
Total 4 files transferred

Discovery Education Upload Ok

7452635 bytes transferred in 16 seconds (449.3K/s)
Total 4 files transferred

Any ideas why the $results variable is not being set when the job is run
from cron or how I can debug this problem.  I am using perl 5.10.0.

Thanks,

ski


--
"When we try to pick out anything by itself, we find it
  connected to the entire universe"            John Muir

Chris "Ski" Kacoroski, [email protected], 206-501-9803
or ski98033 on most IM services
_______________________________________________
Discuss mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/discuss
This list provided by the League of Professional System Administrators
http://lopsa.org/




--
David Parter
Director of Academic Computing Services
University of Wisconsin Computer Sciences Department
[email protected]
608-262-0608

_______________________________________________
Discuss mailing list
[email protected]
https://lists.lopsa.org/cgi-bin/mailman/listinfo/discuss
This list provided by the League of Professional System Administrators
http://lopsa.org/

Reply via email to