Hi, I've got a script that logs into an FTP server and I want it to download a file. It logs in ok checks the file is there but when it does the 'get' it dies with the following message " Bad file number". Heres some of the code;
use Net::FTP; $address ="gamefiles.blueyonder.co.uk"; $hl_path = "/blueyondergames/halflife/patches/win32/"; $ftp = Net::FTP->new($address) or die "Can't connect:$@\n"; $ftp->login() or die "Couldn't login\n"; $ftp->cwd($hl_path) or die "Couldn't change directory to $hl-path: $!\ +n"; @lines_hl = $ftp->dir(".") or die "Can't get a list of files\n"; # lets check if the files are there. &checkFileExists("HL", @lines_hl); sub checkFileExists { print "pt = @_[0]\n"; if (@_[0] == "HL") { $patch = "11081109.exe"; } elsif (@_[0] == "CS") { $patch = "cs1415.exe"; #check this filename } print "patch = $patch\n"; foreach $file (@_) { if ($file =~ "$patch") { print "hit!\n"; &downloadfile($patch); break; } } } sub downloadfile { my $file = "@_[0]"; chomp($file); print "Downloading $file!\n"; $ftp->binary() or die "Can't change to Binary: $!\n"; #change i +t to a binary transfer. $ftp->get($file) or die "error downloading: $!\n"; $ftp->quit(); }
Any ideas why? Thanks Chris

In reply to Bad file number by chaskins

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.