The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script for adding pair of numbers? ShoSho Shell Programming and Scripting 6 12-23-2008 01:38 AM
Need some help with this script -- extra eyes gzs553 Shell Programming and Scripting 15 04-25-2008 11:49 PM
How share X servers for pair programming? siegfried UNIX Desktop for Dummies Questions & Answers 0 03-10-2006 10:57 AM
i broke CDE xyyz UNIX for Advanced & Expert Users 2 03-07-2004 09:32 PM
I think I broke it.... xyyz UNIX for Dummies Questions & Answers 3 10-01-2001 07:17 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 01-12-2009
Styles Styles is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 5
Question Broke Perl Script Second pair of eyes NET::FTPSSL

Hi all,

Let me first start out by saying I'm a perl newbie and hope somebody can help, for the life of me I can't figure out why my script will not find and download a remote file via FTPSSL. What it's supposed to do is find the latest file named simple-test-case_("dd-MM-yyyy-hh-mm-ss").csv i.e.
Quote:
simple-test-case_09-01-2009-08-17-51.csv
and download it. But when I run it (no error or warnings) it acts like it does not find the file and hence not download it. A second pair of eyes and guidance would be much appreciated. I personally feel it's my regex.

Code:
use strict;
use warnings;
use Net::FTPSSL;
use Getopt::Long qw(:config no_ignore_case);


my $hostname = '127.0.0.1';
my $username = 'testuser';
my $password = 'testpass';
my $port = '21';
my $directory = '/';
my $verbose = '1';
my $passive = '0';
my $timeout = "30";
my $version = "0.0.2";
my $input_dir = "input";
my $output_dir = "output";
my $input_trg_file = "simple-test-case.csv";
my $input_csv_file = "simple-test-case.trg";
#Bellow var will be used later
my $output_file = "simple-test-case*.csv";
#
my $encryption = "E";

# creating connection and starting the test

my $ftps = Net::FTPSSL->new($hostname, Debug => $verbose, Port => $port, Encryption => $encryption ) or die "ERROR: Cannot conect to $hostname\n";

if (!$ftps->login("$username","$password")) { 
  print "ERROR: Sever says: ", $ftps->last_message;
  exit 2;
}
if ($input_trg_file eq "") {
  if (!$ftps->list("$directory")) { 
    print "WARNING: server says: " , $ftps->last_message;
    exit 1;
  } else {
    print $ftps->last_message;
  }
} else {
    if (!$ftps->cwd("/$input_dir")) {
      print "WARNING: server says: " , $ftps->last_message;
    exit 1;
  } else {
      if (!$ftps->put("$input_trg_file","/$input_dir/$input_trg_file")) {
        print "WARNING: server says: " , $ftps->last_message;
        exit 1;  
    } else {
      if (!$ftps->put("$input_csv_file","/$input_dir/$input_csv_file")) {
        print "WARNING: server says: " , $ftps->last_message;
        exit 1;
      } else {
        if (!$ftps->cwd("/$output_dir")) {
          print "WARNING: server says: " , $ftps->last_message;
          exit 1;
          } else {
          sleep(10);
          my @lines = grep { /^simple-test-case./i } $ftps->list();
          foreach my $name (@lines) { 
          if (!$ftps->get("$name, /tmp/$name")) {
              print "WARNING: server says: " , $ftps->last_message;
            } else {
              my @message = $ftps->last_message;
              chomp @message;
              print "OK: ", "$message[0] $message[1]\n";
              exit 0;
             }
           }
         }
       }
     }
   }
 } 

$ftps->quit;
Thanks in advance,
Eric
 

Bookmarks

Tags
perl net::ftpssl

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0