On Apr 28, 9:31 am, dthack...@gmail.com (Dave Thacker) wrote: > Hi, > I need to pull a file or files down every day that contain a specific > string. Here's my code. > > #!/usr/bin/perl > use strict; > use Net::SCP; > > my $scp=' '; > open (LOG, ">>/home/wesaysopost/logs/retrieve-wesayso-results.log") or die > "Can't open logfile"; > LOG-> autoflush(1); > > print LOG "Starting Retrieval Process"; > $scp = Net::SCP->new ( "theserver.wesayso.com", "mylogin"); > $scp->cwd("postingscript") or die "Can't change directories"; > $scp->get ("acme_posting*") or die "Can't retrieve results"; > close LOG; > exit; > > The file I'm retrieving is acme_posting20110415.txt (date changes every > day) > > The file is found, but it's being saved as acme_posting* > > I'm not specifying a local file name when I get the file, why is SCP saving > it under a different name?
Because perl doesn't know what the actual wildcarded transfer will return before the call returns. If fact, several files might be returned. How would perl know which one was the target... So, the basename of the remote file is used to generate the local file name. In this case basename('acme_posting*') just becomes the identical name "acme_posting*" Any reason you can't just specify an exact filename each day.. for instance: ($day, $mon, $yr ) = (localtime time())[3,4,5]; $file = sprintf( "acme_posting%d%02d%02d", $yr+1900, $mon, $day ); -- Charles DeRykus -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/