"Ryan Frantz" <[EMAIL PROTECTED] med-llc.com> To <[EMAIL PROTECTED]>, 01/24/2006 03:17 <beginners@perl.org> PM cc Subject RE: rename file on ftp server
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Tuesday, January 24, 2006 3:05 PM > To: beginners@perl.org > Subject: rename file on ftp server > > All, > > I have a task to complete for a user. He wants me to rename a file on a > remote server so that he can pick it up. > I am trying to use a reg exp or a blog but this is not working. Any > tricks > of the perl trade will be mucho appreciated! > The file format is OhioHealthyyymmdd[0-9].xml > The [0-9] is a 6 digit PID I assume but changes every time the file is > created. > So the filename for example looks like OhioHealth20040124989893.xml > > thank you! > > #!/usr/bin/perl > use strict; > use warnings; > use Net::FTP; > use MIME::Lite; > > my ($monster_date,$fref) = 0; > > sub new_date { > > my ($year,$month,$day) = (localtime)[5,4,3]; > sprintf ("%04d%02d%02d", ($year += 1900), $month+1,$day); > } > my $passed_new_date = new_date(); > > sub new_date_append { > > return $monster_date = "OhioHealth$passed_new_date"; > } > $fref = \&new_date_append(); > > > sub ftpme { > > my $remotehost="ftp.monster.com"; > my $remotedir="outbound"; > my $user="xxxxxxxx"; > my $pass="xxxxxxxx"; > my $data=$$fref; > my > $ftplog="/psofthr/hr88prd/intf/monster/log/interface_monster.log"; > > open (FTPLOG, ">>$ftplog") || die "could not open file: > $ftplog $!"; > my $ftp = Net::FTP->new($remotehost, Debug => 10) > || do {print FTPLOG "\tCannot connect to $remotehost: > monster.com: $!"; }; > $ftp->login($user, $pass) || do {print FTPLOG "\tLogin > failed!: $!"; }; > $ftp->binary(); > $ftp->cwd($remotedir); > $ftp->rename("$$fref\[0-9].xml", "OhioHealth.xml") || do To match one or more of the previous characters, use the '+' operator: "$$fref\[0-9]+.xml" > {print FTPLOG "\tFTP get from monster.com failed!: $!"; }; > $ftp->quit; > } > > if ( $passed_new_date and $$fref ) { > print "YES\n"; > print $passed_new_date,"\n"; > print $$fref,"\n"; > ftpme(); > } > # else { > # "email warning" > # } > > Derek B. Smith > OhioHealth IT > UNIX / TSM / EDM Teams > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> ***************************************************************** ***************************************************************** your solution does not work.... I am not a noob so I have tried this already. thank you though! __DEBUG__ FTP is returning the RNFR command OhioHealth20060124[0-9]+.xml 550 OhioHealth20060124[0-9]+.xml: The system cannot find the file specified. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>