FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old February 4th, 2004, 04:16 PM
squidly squidly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 71 squidly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 28 sec
Reputation Power: 5
little problems with MPUT (ftp & perl script)

I am trying to upload all .csv files in c:\temp\

I am getting an error whenever i run the code:
"can't get the object put from "c:\temp\*.csv" perhaps you forgot to load it.

Is there a simple way to upload all files of a certain type to an ftp server?


here is my code:

Code:
use Net::FTP;
    
        $ftp = Net::FTP->new("ftp.myserver.com");
        $ftp->login("uesername","pass");
        $ftp->cwd("/var/www/html/data/uploads/");
       
        
sub mput { my($ftp,$pattern) = @_; 
foreach my $upload (glob($pattern)) { $ftp->put($upload) or warn $ftp->message; } } 

&mput("c:\\temp\\*.csv");

$ftp->quit;


Thanks for the help

Reply With Quote
  #2  
Old February 4th, 2004, 04:27 PM
squidly squidly is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 71 squidly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 28 sec
Reputation Power: 5
i changed it to this:

Code:

 for (glob("c:\\temp\\*.csv")) {
$ftp->put($_);
}


and it works with no errors, i just don't get any files uploaded. Any hints or tips as to why the files aren't going?

Reply With Quote
  #3  
Old February 4th, 2004, 06:52 PM
aplonis aplonis is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Kalamazoo Michigan USA
Posts: 2 aplonis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Um... Your &mput takes 2 args, yes? In your call to mput() I count only one arg.

FWIW... Here is a Perl script I just cobbled together to do the opposite: download. I banged it together for my boss. Tomorrow I'll try to compile it with PAR or Perl2Exe for Win2K so he won't even have to install Perl.

This is my actual script, with only the IP, user and passwd obfuscated. I just ran it. It works.

If you change the 'get' to 'put' and build your list other than from 'ls' it shouldn't be hard at all to tweak. This is my first Net::FTP script, cobbled from another by somebody else. I am using 'get' and a 'foreach' on a list with matching...since there is no 'mget' in Net::FTP that I could find.

Code:
use strict;
use warnings;
use Net::FTP;

my $host = "666.666.666.666";
my $user = "foo";
my $pw   = "bar";
my $path = "outgoing/foobar";

if ( my $ftp = Net::FTP->new($host) ) {
        print "Logging in to '$host' as user '$user'.\n";
        $ftp->login($user,$pw) or die "Could not login";
        $ftp->pasv();
        print "Changing directory to '$path'\n";
        $ftp->cwd($path) or die "could not cwd $path";
        $ftp->ascii;
        my @files = $ftp->ls;
        print "Found these files: \n\t" . 
                join( "\n\t", @files ) . 
                ".\n";
        foreach my $file (@files) {
                if ( $file =~ /.*progress|monitor|gui|station.*txt/ ) {
                        print "Downloading file: $file.\n";
                        $ftp->get($file) or print "Oops! Could not get $file\n";
                }
        }

        $ftp->close(); }

else { print "Could not connect.\n"; }

print "All done.\n";

Last edited by aplonis : February 4th, 2004 at 07:13 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > little problems with MPUT (ftp & perl script)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway