Having a problem with a FTP Script using perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Having a problem with a FTP Script using perl
# 1  
Old 12-19-2007
Having a problem with a FTP Script using perl

Hello All,

I have a problem that has me stumped. I am using perl to do some ftp'ing of files. I have the script in place on another environment that is functioning flawlessly. But after tweaking it to the new environment I can't get it to function. I have a search string that searches for the file name and then executes the file and deletion of that file after the ftp. The only difference between the two environments is the file name is slightly different. Any help would be greatly appreciated. I use a XML file that contains the host information. I have included the following information:

Functioning Environment:
File Defination:file.serv1.YYYYMMDDhhmm-[0-9]{4}.log
File name: file.serv1.200712192300-0500.log

XML File Info:
<host_list hostname="serv1" althostname="" username="ftpuser" password="passwd">
<file_list>
<remote_dir>/app/logs</remote_dir>
<local_dir>targetlocation/targetdirectory</local_dir>
<remote_name>file.serv1.YYYYMMDDhhmm-[0-9]{4}.log</remote_name>
</file_list>

FTP PERL File:

$searchFilter = $remoteName."\$";
$searchFilter =~ s/YYYYMMDDhhmm/[0-9]{12}/;

@files = sort grep (/$searchFilter/, @files);

Non-Functioning Environment:
File Defination: fileYYYYMMDD.log
File name: file20071219.log

XML File Info:
<host_list hostname="serv1" althostname="" username="ftpuser" password="passwd">
<file_list>
<remote_dir>/app/logs</remote_dir>
<local_dir>targetlocation/targetdirectory</local_dir>
<remote_name>fileYYYYMMDD.log</remote_name>
</file_list>

FTP PERL File:

$searchFilter = $remoteName."\$";
$searchFilter =~ s/YYYYMMDD/[0-9]{8}/;

@files = sort grep (/$searchFilter/, @files);


Any Ideas?

Thanks in Advance.

Last edited by scottzx7rr; 12-19-2007 at 05:43 PM..
# 2  
Old 12-19-2007
Quote:
Originally Posted by scottzx7rr
$searchFilter = $remoteName."\$";
....
$searchFilter = $remoteName"\$";
You have dropped a period.
# 3  
Old 12-19-2007
Sorry that is a typo. I have the period there. I have updated the orginal post to reflect the typo.
# 4  
Old 12-19-2007
Quote:
Originally Posted by scottzx7rr
fileYYYYMMDD.log
file120071219.log
You have an extra 1 before the year date there.....
# 5  
Old 12-19-2007
Yeah that was just the example I typed for reference. It doesn't have that 1 in the file name. Here also is the output for what it is looking for so it appears to posting the information from the xml to the ftp script but the search string appears to be the issue I think:

DEBUG [3390] : Processing Fileset: remoteDir->targetlocation/targetdirectory/, remoteName->fileYYYYMMDD.log

Last edited by scottzx7rr; 12-19-2007 at 05:55 PM..
# 6  
Old 12-19-2007
Can you see the complete file list before it does the grep and sort?
# 7  
Old 12-19-2007
It was a typo in the shell script that I use to call the perl script. It was pointing to the development script, so all the changes I was making were not working because I was using the wrong script. LOL Too many to-do items and not enough time to do them. LOL Thanks for your help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

FTP download using perl script

Need assistance I have a script which i can download the files from ftp server using perl . But i want to download multiple files at a time #!/usr/bin/perl -w use Net::FTP; $ftp = Net::FTP->new("ftp.ncdc.noaa.gov"); $ftp->login('username', 'password'); $ftp->cwd("<dir>");... (9 Replies)
Discussion started by: ajayram_arya
9 Replies

2. Shell Programming and Scripting

Unable to get the size of remote file using Net::FTP Perl Script

Hi, I am using below piece of code to get the size of the remote file. $ftp->cwd($destination) or $error=$ftp->message; if(!$error) { $ftp->put($file) or $error=$ftp->message; print "FTP size = \n"; ... (3 Replies)
Discussion started by: FarooqOnline
3 Replies

3. Shell Programming and Scripting

script FTP in perl

this script should search directories read,,search for file for daily reports. you must provide the beginning day, ending day and month. this script will pull files for days and month specified and Ftp them to another server. Thanks for any help you provide (2 Replies)
Discussion started by: lemseffert
2 Replies

4. Shell Programming and Scripting

problem while using FTP in shell script

Hi all, I am having problem while using FTP in shell script.I am downloading a file from other machine.Part of file name is known to me(in red) 20100114123814.portin.virginsubs.extract What i am doing is trying to get the file using get command with wild card "*" (see below) but it fails... (1 Reply)
Discussion started by: vinoo128
1 Replies

5. Shell Programming and Scripting

FTP Perl Script File Size Mismatch.

Hello, I've written a Perl script that copies a set of files from one server to another. Prior to transferring a file the script gets the file size from the source system and compares this to the file size received in the target system. Except that the file sizes are slightly different. ... (1 Reply)
Discussion started by: mbb
1 Replies

6. Solaris

FTP Script Problem

Hi Everybody, I am working on FTP Script (i,e Parser.sh,Upload.sh) and the contents of the same are mentioned below .., #!/bin/bash if ; then echo "Usage ./Parser.sh IP USERNAME PASSWORD SOURCE FILENAME DESTINATION where IP ------------- IP address of remote... (0 Replies)
Discussion started by: prasanth_babu
0 Replies

7. Shell Programming and Scripting

Help deciphering FTP get perl script

I found this very useful perl script that will check a remote ftp server, search for files of a specific time and get them. When I run the script it works, but it gave me the following error: Couldn't get filename_12-13-07.txt Bad file number What in this script would cause this? I know... (2 Replies)
Discussion started by: bbbngowc
2 Replies

8. Shell Programming and Scripting

FTP script and problem

We have a script where we're trying to ftp to an outside ftp server, but it keeps failing with the error: 421 Service not available, remote server has closed connection if we ftp <server> and manually enter the username and password from the Unix box it's just fine. But when we try to... (1 Reply)
Discussion started by: lawadm1
1 Replies

9. Shell Programming and Scripting

FTP Script Problem

Hi, Firstly, I would like to admit that I am a scripting newb. :) Now, to my question: I am writing a script that FTPs a bunch of logs from one server to another, it will be scheduled in Cron to run every 20 minutes. Currently, the file transfer part of the script is fine. However,... (2 Replies)
Discussion started by: reebz
2 Replies

10. UNIX for Advanced & Expert Users

problem with ftp script...please help

Hi, I'm writing an ftp script that is trying to connect to a remote NT box. Here is my script: ftp -i ipaddress user username password ascii cd db_Backup lcd /home/dB_backups put *.sql bye When I run this script I get the following error: 500 'AUTH GSSAPI': command not... (2 Replies)
Discussion started by: vancouver_joe
2 Replies
Login or Register to Ask a Question