Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Net::FTP

by nimdokk (Vicar)
on Oct 01, 2003 at 18:21 UTC ( [id://295716]=note: print w/replies, xml ) Need Help??


in reply to Net::FTP's get() does not handle wildcards

If you know when the file is being generated, perhaps you could use Time::localtime (or something similar) to (re)build the filename for each host and simply do a get on that filename, perhaps storing it in a scalar variable, something like: $my_file="${hostname}shar${date}.${time}";. I'm sure there are more (and better) ways to do it, but that is one possible idea.


"Ex libris un peut de tout"

Replies are listed 'Best First'.
Re: Re: Net::FTP
by Anonymous Monk on Oct 02, 2003 at 10:17 UTC
    Dear monks, Thanks for the *very* helpful suggestions. I have decided to follow RMGir and Abigail's (duplicate node) suggestion, and grep through an ls to find the file that way. Sometimes I can't see these things and need a nudge in the right direction :) See code snippet below:

    if (@dirlist = ($ftp->ls)) { foreach $_ (@dirlist) { if (s/(\w+shar\d\d\d\d\d\d\.\d\d\d\d)/$1/) { $file = $1 if ($ftp->get($file)) { } else { print "$host: Got directory listing, but couldn't get file.\n" +; } } } }
    It could probably be written a lot simpler than that, but I like to keep things in a format I can easily understand.

    Thanks again.
      I think that there might be a problem with that. It might work, but I would suggest cleaning up one line a bit. Instead of:
      if (s/(\w+shar\d\d\d\d\d\d\.\d\d\d\d)/$1/)

      I would suggest:

      if (m/(\w+shar\d\d\d\d\d\d\.\d\d\d\d)/)
      What you are doing with s/// is substituting your regular expression for $1. The parenthesis around the expression delimit(?) $1. So it would appear that you are substituting the regular expression for itself. Then of course setting your variable $file to be equal to $1. Note the m/// in the second if statement. Also, your regular expresion could match on more than one file that fit that pattern if several files fit that scheme.


      "Ex libris un peut de tout"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://295716]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-20 02:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found