Click here to get back home

filecopy from remote machine to local machine

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
filecopy from remote machine to local machine anu 02-07-2006
Posted by anu on February 7, 2006, 8:50 am
Please log in for more thread options


Hi,

I am tryin to copy a tar file from remote machine to local machine
using Net:Telnet.
I am using the following logic :

my(@Out) = $objTelnet->cmd("cat $FromFile");
$strArg2 = basename $FromFile if $strArg2 eq '.';
open (FH, ">$strfnArg2") or die "Can't open $strfnArg2 for
writing: $!";
print FH @Out;

#closing local file

close FH or die "Can't close $strfnArg2 : $!";

print ("File fetched from remote host successfully");


Note: here strArg2 is the filename that is passed as an argument.


This logic is working fine for ascii files but doesnt for tar
files."cat file.tar" i dont know if that is fine.

Can anyone please help me out here.


And also please do clarify this doubt of mine----" Can we open a
filehandle for a file on the remote machine using Net::Telnet " if so
how?


thanx
Anu.


Posted by Paul Lalli on February 7, 2006, 9:28 am
Please log in for more thread options


anu wrote:
> I am tryin to copy a tar file from remote machine to local machine
> using Net:Telnet.

Why? Telnet is not a file transfer proticol. Why not use a module
that *does* interface with a file transfer proticol? Such as Net::FTP
or Net::SCP?

> I am using the following logic :
>
> my(@Out) = $objTelnet->cmd("cat $FromFile");
> $strArg2 = basename $FromFile if $strArg2 eq '.';
> open (FH, ">$strfnArg2") or die "Can't open $strfnArg2 for
> writing: $!";
> print FH @Out;
>
> #closing local file
>
> close FH or die "Can't close $strfnArg2 : $!";
>
> print ("File fetched from remote host successfully");
>
>
> Note: here strArg2 is the filename that is passed as an argument.
>
>
> This logic is working fine for ascii files but doesnt for tar
> files.

"doesn't work" is the worst of all possible error descriptions. What
happens? Syntax error? Run-time error? Empty file? No file?
Corrupt file?

How can we help you when you won't tell us what goes wrong?

> "cat file.tar" i dont know if that is fine.

I don't know what that means.

> And also please do clarify this doubt of mine----" Can we open a
> filehandle for a file on the remote machine using Net::Telnet " if so
> how?

Nothing I saw in my (very brief) examination of the docs suggests that
you can. However, check out Net::SSH, which does seem to have that
ability.

Paul Lalli


Posted by Paul Lalli on February 7, 2006, 9:36 am
Please log in for more thread options


Paul Lalli wrote:
> anu wrote:
> > And also please do clarify this doubt of mine----" Can we open a
> > filehandle for a file on the remote machine using Net::Telnet " if so
> > how?
>
> Nothing I saw in my (very brief) examination of the docs suggests that
> you can. However, check out Net::SSH, which does seem to have that
> ability.

Nope, I'm wrong. Read the docs incorrectly. Net::SSH does not have
this ability either.

I once again suggest an actual file transfer module - Net::FTP,
Net::SFTP, Net::SCP, etc...

Paul Lalli


Posted by anu on February 7, 2006, 10:50 pm
Please log in for more thread options


Well, the constraints put forward to me dont let me use any of the file
transfer modules of perl. All that I can use are the Net::Telnet and
the Net::SSH module and hence I was trying out tht logic for file
transfer.

"doesn't work" is the worst of all possible error descriptions. What
happens? Syntax error? Run-time error? Empty file? No file?
Corrupt file?

Sorry for that , let me now rephrase that ......when I try that logic
out with Net::Telnet
-- in case of larger files an empty file gets copied
-- in case of smaller files the a corrupt file gets copied

I figured this may be was because tar files are binary files and hence
I tried setting the binmode to 1 which wouldnt translate the newline
characters but then the problem still persists.


Posted by harryfmudd [AT] comcast [DOT] on February 8, 2006, 10:28 am
Please log in for more thread options


anu wrote:
> Well, the constraints put forward to me dont let me use any of the file
> transfer modules of perl. All that I can use are the Net::Telnet and
> the Net::SSH module and hence I was trying out tht logic for file
> transfer.
>
> "doesn't work" is the worst of all possible error descriptions. What
> happens? Syntax error? Run-time error? Empty file? No file?
> Corrupt file?
>
> Sorry for that , let me now rephrase that ......when I try that logic
> out with Net::Telnet
> -- in case of larger files an empty file gets copied
> -- in case of smaller files the a corrupt file gets copied
>
> I figured this may be was because tar files are binary files and hence
> I tried setting the binmode to 1 which wouldnt translate the newline
> characters but then the problem still persists.
>

Hmm. That's what I was going to suggest. The next step is probably to
uuencode the tar file, cat _that_ onto the link, and uudecode it after.
Nothing magic about uu(en|de)code, anything that ASCII-fies the file is
worth a try.

Don't you hate it when you are both required and forbidden to do a job?

Tom Wyant

Similar ThreadsPosted
how to execute command on remote machine September 21, 2005, 12:40 am
DBD::Pg on machine without Postgres November 3, 2004, 11:16 am
How to know what perl modules on my machine October 8, 2004, 4:04 pm
DBD:Excel on unix machine March 9, 2006, 11:18 am
installing www::mechanize on a windows98 machine November 13, 2005, 8:31 pm
Namespace for Z-machine parse/translate module July 29, 2004, 10:02 am
GD incorrectly renders Arabic on Win32 machine March 6, 2005, 9:28 pm
Trouble installing storable 2.13 with perl 5.8.0 on redhat 9 machine December 10, 2004, 12:06 am
Running compiled Inline C perl scripts on more than one machine February 9, 2006, 12:12 pm
Remote.pm (File::Remote) error handling question January 29, 2007, 12:57 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap