Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

ok granted my Perl coding is very novice, but I need to write an automation script to push logfiles to a logserver. We opted to use TFTP because it is on a private network and TFTP doesn't require authentication. So here is what I have written:
use Net::TFTP; my $tftp; my $err; my $putfile; $tftp = Net::TFTP->new("server.com", BlockSize => 1024); $tftp->binary; $putfile = $tftp->put("./test.log"); #$tftp->quit; $err = $tftp->error; print ("error is $err.\n"); print ($@."\n"); print ("put file output is $putfile.\n");
The out put that it produces looks like this error is . put file output is Net::TFTP::IO=GLOB(0x8064d1c). So while everything seems to be working ok, here are my 2 questions: 1. Why doesn't Net::TFTP report back when the file is already present on the tftp server. It doesn't overwrite it if it is. 2. How can I get it to move the file to a directory instead of just to the root. I know that
$putfile = $tftp->put("./test.log");
supports REMOTE_FILE, but apparently not something like remote path. Thanks for the help.

Replies are listed 'Best First'.
Re: Net::TFTP is stumbling me up
by bunnyman (Hermit) on Sep 18, 2003 at 21:24 UTC

    put ( LOCAL, REMOTE_FILE , OPTIONS)

    If the LOCAL option is missing the put will return a filehandle. This filehandle must be written to ASAP as the server will otherwise timeout.

    You have only supplied one argument, which means the return from put() is a filehandle. You probably didn't want to do that. So try using $tftp->put("localfile-name", "remotefile-name");

Re: Net::TFTP is stumbling me up
by vek (Prior) on Sep 18, 2003 at 23:35 UTC

    Always check the documentation first. A quick browse of the Net::TFTP documentation would have told you all you need to know. See bunnyman's post above.

    -- vek --