Professional Web Applications Themes

filecopy from remote machine to local machine - PERL Modules

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 ...

  1. #1

    Default filecopy from remote machine to local machine

    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.

    anu Guest

  2. #2

    Default Re: filecopy from remote machine to local machine

    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

    Paul Lalli Guest

  3. #3

    Default Re: filecopy from remote machine to local machine

    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

    Paul Lalli Guest

  4. #4

    Default Re: filecopy from remote machine to local machine

    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.

    anu Guest

  5. #5

    Default Re: filecopy from remote machine to local machine

    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
    harryfmudd [AT] comcast [DOT] net Guest

  6. #6

    Default Re: filecopy from remote machine to local machine

    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.
    Is this some kind of bizzaro-world homework assignment? Who/What puts
    contraints that you can't use File Transfer modules for File Transfers?

    Net::Telnet and Net::SSH simply have nothing to do with transferring
    files. You may as well be told you can only use Math::BigInt and
    Getopt::Long to transfer the 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?
    >
    > 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
    Define larger. Define smaller. Define corrupt.
    > 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.
    At this point, my recommendation is to write a Perl script that simply
    shells out to the actual scp or ftp programs on your machine.

    Paul Lalli

    Paul Lalli Guest

Similar Threads

  1. Remote access to web pages on local machine
    By jyurkonis in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: July 9th, 08:40 PM
  2. Replies: 2
    Last Post: June 17th, 12:08 AM
  3. SSL on local machine...
    By Paul M in forum ASP.NET Security
    Replies: 1
    Last Post: December 5th, 11:05 AM
  4. Setting folder permissions on remote machine / remote domain
    By Tim Chandler in forum ASP.NET Security
    Replies: 0
    Last Post: October 7th, 04:17 PM
  5. Replies: 1
    Last Post: June 26th, 09:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139