Home > Archive > PERL Beginners > December 2007 > FTP file handle question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
FTP file handle question
|
|
| Robert W Mr CTR USA AMC Sturdevant 2007-12-27, 7:01 pm |
| Hi group,
I'm troubleshooting a perl 5.6 Win32 app that uses Net::FTP. I am trying
to ftp using a file handle instead of a local file name.
POD says something like $ftp->put(LOCAL_FILE [REMOTE_FILE]) where
LOCAL_FILE may be a file name or a file handle. I know $filename does
exist, I can see it!
This works: $ftp->put( $filename, $somename) ;
But this fails with "Cannot open local file HANDLE: No such file or
directory"
open( HANDLE, "< $filename");
$ftp->put( HANDLE, $somename);
open() does open the file. fileno() says a descriptor is assigned. The
error is thrown by put(), specifically IO::Handle. Can someone tell me
what I am doing wrong??
Thanks,
Sturdy
| |
| John W. Krahn 2007-12-27, 7:01 pm |
| Sturdevant, Robert W Mr CTR USA AMC wrote:
> Hi group,
Hello,
> I'm troubleshooting a perl 5.6 Win32 app that uses Net::FTP. I am trying
> to ftp using a file handle instead of a local file name.
>
> POD says something like $ftp->put(LOCAL_FILE [REMOTE_FILE]) where
> LOCAL_FILE may be a file name or a file handle. I know $filename does
> exist, I can see it!
>
> This works: $ftp->put( $filename, $somename) ;
>
> But this fails with "Cannot open local file HANDLE: No such file or
> directory"
>
> open( HANDLE, "< $filename");
You should verify that the file was opened correctly:
open HANDLE, '<', $filename or die "Cannot open '$filename' $!";
> $ftp->put( HANDLE, $somename);
>
> open() does open the file. fileno() says a descriptor is assigned. The
> error is thrown by put(), specifically IO::Handle. Can someone tell me
> what I am doing wrong??
perldoc -q "How do I pass filehandles between subroutines"
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
|
|
|
|
|