Net::SCP is saving a file name with a wild card
--bcaec5314ba9b798be04a1fd15d0
Content-Type: text/plain; charset=ISO-8859-1
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?
Thanks in Advance!
Dave
--bcaec5314ba9b798be04a1fd15d0--
Re: Net::SCP is saving a file name with a wild card
On Apr 28, 9:31=A0am, dthack... [at] gmail.com (Dave Thacker) wrote:
> Hi,
> I need to pull a file or files down every day that contain a specific
> string. =A0 Here's my code.
>
> #!/usr/bin/perl
> use strict;
> use Net::SCP;
>
> my $scp=3D' ';
> open (LOG, ">>/home/wesaysopost/logs/retrieve-wesayso-results.log") or di=
e
> "Can't open logfile";
> LOG-> autoflush(1);
>
> print LOG "Starting Retrieval Process";
> $scp =3D Net::SCP->new ( "theserver.wesayso.com", "mylogin");
> $scp->cwd("postingscript") =A0or 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 =A0 (date changes eve=
ry
> 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 savi=
ng
> 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 ) =3D (localtime time())[3,4,5];
$file =3D sprintf( "acme_posting%d%02d%02d",
$yr+1900, $mon, $day );
--
Charles DeRykus
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
RE: :SCP is saving a file name with a wild card
Dave, in looking at the documentation for Net::SCP, it does not appear that
it can accept a wildcard. It looks like it has to be the exact name of the
file that you wish to retrieve. It might be creating a file with nothing in
it. When it retrieves that file, is it really the file, or just a zero byte
file?
Tim
-----Original Message-----
From: Dave Thacker [mailto:dthacker9 [at] gmail.com]
Sent: Thursday, April 28, 2011 12:31 PM
To: beginners [at] perl.org
Subject: Net::SCP is saving a file name with a wild card
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?
Thanks in Advance!
Dave
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/