#!/usr/bin/perl -w # this script by Stef Caunter July 2001 # works well with shallow directory structures # prints a list of the files in pwd with numbers # enter the number, upload the file # stef@caunter.ca use Net::FTP; opendir DIR, "."; @choice = (readdir DIR); @choice = sort(@choice); shift(@choice); shift(@choice); $present_dir=`pwd`; @dirs=split(/\//, $present_dir); @dir_only=pop(@dirs); $num = 0; foreach $_ (@choice) { format= @<< @<<<<<<<<<<<<<<<< $num, $_ . (++$num); write (); } print "enter # "; $file = (); chomp $file; $list = `ls -l "$choice[$file -1]"|tr -s ' '|cut -d' ' -f5-9`; print "$list"; # put in your site here $hostname = 'foo.ca'; # your username, eh? $username = 'bar'; print "password: "; `stty -echo`; chomp ($password = ()); $ftp = Net::FTP->new($hostname); #open an ftp connection to server $ftp->login($username, $password); #login to the server # you can put in $ftp->cwd("/some/other/dir"); if you want $result = $ftp->put("$choice[$file -1]"); #put the file $status = $?; # check the exit status if ($status =~ 0) { # if okay print "$result PUT to $hostname exit status $status: done...\n"; } elsif ($status != 0) { # say there was a problem die "exit status of $status, some kind of network problem?"; } $ftp->quit; `stty echo`; $ftp = Net::FTP->new($hostname, PASSIVE=>0); #open an ftp connection to server $ftp->login($username, $password); #login to the server @result = $ftp->dir("$choice[$file -1]"); if (@result) { open (FH, ">fh")||die "eh, $!\n"; print FH "@result"; close FH; open (FH, "fh")||die "eh, $!\n"; $_ = ; s/ +/ /g; print; print "\n"; } else { print "$list -- #$file -- isn't in $hostname\n"; } `rm fh 2>/dev/null`;