#!/usr/bin/perl -w # # use strict; use Net::FTP; use Net::FTP::File; use Term::ReadKey; use diagnostics; my $username; my $password; my $directory; my $localfile; my $remotefile; my $filename; my $domain; print "Luke's Neato FTP Script, Version 1.1\n"; print "Domain: "; chomp($domain = <STDIN>); my $ftp; if($ftp = Net::FTP->new($domain)) { print "Successfully connected to $domain\n"; } else { print "Couldn't connect:\n\t" . $ftp->message ; quit(); } print "Username: "; chomp($username = <STDIN>); ReadMode 2; print "Password: "; chomp($password = <STDIN>); ReadMode 0; if($ftp->login($username, $password)) { print "\nSuccessfully logged in as $username\@$domain\n"; } else { print "Couldn't Login:\n\t" . $ftp->message ; quit(); } print "Working Directory: "; chomp($directory = <STDIN>); if($ftp->cwd($directory)) { # change working directory print "Successfully changed working directory to $directory"; } else { print "Couldn't change working directory:\n\t" . $ftp->message ; quit(); } my @filearray; my $input = ''; my $count = 0; print "\n"; while () { print "File to upload: "; chomp($input=<STDIN>); if ($input ne '') { push @filearray, $input; $count++; next; } if ($input eq '') { last; } } foreach my $element (@filearray){ my $chvalue = 0; if($element =~ /\.(.+?)$/){ if($1 eq 'cgi' || $1 eq 'pl' || $1 eq 'pm') { $ftp->ascii; # transfer in ASCII mode $chvalue = 755; # chmod it to 755 } else { $ftp->binary; $chvalue = 644; } if($ftp->put($element)) { print "$element uploaded successfully to $directory at $do +main\n"; if($ftp->chmod($chvalue, $element)) { print "$element successfully chmoded to $chvalue.\n"; } else { print $ftp->message; quit(); } } else { print "Couldn't put $element:\n\t" . $ftp->message ; quit(); } } else { if($ftp->put($element)) { print "$element uploaded successfully to $directory at $do +main\n" } else { print $ftp->message; quit(); } } } quit(); # quits, fancy that. sub quit { $ftp->quit(); print "Press any key to exit"; chomp(my $chomp = <STDIN>); exit; }

In reply to ftp.pl by Spidy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.