gammaX500 has asked for the wisdom of the Perl Monks concerning the following question:
use Tk; use Tk::DropSite; use Net::FTP; use Net::SMTP; use strict; use vars qw($top $drop); $top = MainWindow->new(); $top -> title('cor-techs.net Drop Zone'); $top -> Label(-text => "Cor-Techs.net Drop Zone:")->pack; $top -> geometry('600x250'); $drop = $top->Scrolled('Listbox', -scrollbars => "osoe", )->pack; $drop-> configure(-width=>500); my $quit = $top-> Button(-text => 'Quit', -command => \&quit)->pack(); $quit-> configure(-width=>10); $quit-> configure(-background=>'red',-foreground=>'white'); # Tell Tk that $drop should accept drops. $drop-> DropSite (-dropcommand => [\&accept_drop, $drop], -droptypes => ($^O eq 'MSWin32' ? 'Win32' : ['KDE', 'XDND', 'Sun']) ); MainLoop; sub accept_drop { my($widget, $selection) = @_; use vars qw( $filename %files $cleanedName); $filename = $widget->SelectionGet(-selection => $selection, 'STRING'); if (defined $filename) { $widget->insert(0, "Transferred: ".$filename); $cleanedName = ftpIt($filename); sendmail($cleanedName); } } sub ftpIt { my $ftpdFile = $_[0]; my($directory, $filename) = $ftpdFile =~ m/(.*\\)(.*)$/; my $urlFriendly = $filename; $urlFriendly =~ s/[^a-zA-Z0-9_\.-]/_/ig; ## COMMENT OUT THE FTP PART - not the source of the error # my $ftp = Net::FTP -> new("www.cor-techs.net") or die "Can't conn +ect\n"; # $ftp -> login("ftplogin", "passwd") or die "Couldn't login\n"; # $ftp -> binary() or die "Couldn't send as binary\n"; # $ftp -> cwd("/c:/websites/cortechs/downloads") or die "Couldn't c +hange dir\n"; # $ftp -> put($ftpdFile) or die "Couldn't transfer file\n"; # $ftp -> rename ( $filename , $urlFriendly ) or die "Couldn't rena +me file\n"; # $ftp -> quit() or warn "Couldn't quit. Oh well.\n"; return ($urlFriendly); } sub sendmail { my $filename = $_[0]; # Connect to the server ann\@cor-techs.net; my $smtp = Net::SMTP -> new("mail.cor-techs.net"); die "Couldn't connect to server" unless $smtp; my $MailFrom = "ann\@cor-techs.net"; my $MailTo = "ann\@cor-techs.net"; my $message = "A file has been uploaded:\n\n"; $message = $message."http://www.cor-techs.net/downloads/$filename\ +n\n"; $message = $message."Login Info\n****************************\n"; $message = $message."Username: username\n"; $message = $message."Password: password\n"; # $smtp-> mail( $MailFrom ); # $smtp-> to( $MailTo ); # Start the mail # $smtp->data(); # Send the header. # $smtp->datasend("To: ann\@cor-techs.net"); # $smtp->datasend("From: ann\@cor-techs.net\n"); # $smtp->datasend("Subject: File Upload Info\n"); # $smtp->datasend("\n"); # Send the message # $smtp->datasend($message); # Send the termination string # $smtp->dataend(); # $smtp->quit(); } sub quit { exit; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Building standalone application with Perl Dev Kit 6 fails, but script works
by ChrisR (Hermit) on Nov 16, 2004 at 21:21 UTC | |
by gammaX500 (Novice) on Nov 16, 2004 at 21:44 UTC |