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

Would it be allowed to create a FTP session over a Telnet session's object created using Net::Telnet My requirement is basically I have a Telent session with a server A, this basically must copy files that are on server B to server C. how would I be able to achieve this?

Replies are listed 'Best First'.
Re: ftp or scp session on a telnet object
by JavaFan (Canon) on Apr 14, 2011 at 14:37 UTC
    Telnet is a protocol to execute commands remotely. It's not for transfer of files. There are many other protocols that will do that: scp, ftp, rsync, http to name a few well known ones.

    Pick a protocol that the remote site supports and use that instead of trying to use the telnet object.

Re: ftp or scp session on a telnet object
by salva (Canon) on Apr 14, 2011 at 13:18 UTC
    There are too many missing details from your question to be able to give you any useful answer.

    How would you do it by hand?

      If I need to explain over a manual session. say as follows open a putty session to server A. do a telnet to server B. perform and ftp to server C and copy files to server B. I need the above because, we are running through an automation client that actually runs on A, this uses net::telnet and achieves a session with B. Further I need to copy the files from Server C on B.
        So, you want to run an script in A that opens a Net::Telnet connection to B and from there drives a SFTP client that connects to C and gets some files from there, right?

        The task seems doable through Net::Telnet, what have you tried so far? What issues have you found?

Re: ftp or scp session on a telnet object
by roboticus (Chancellor) on Apr 14, 2011 at 15:04 UTC

    nrm:

    While I agree with JavaFan, if you really must use telnet, then I'd suggest converting the file into a text format (if it isn't already). Then you can tell the remote box to dump the contents of the file to the terminal, and use your telnet object to capture the data. Then you can convert the file back into its original form. Horrendous, but it would work if you put some time and effort into it.

    But it would be much simpler to use ftp, scp, or some such to do the job.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: ftp or scp session on a telnet object
by believer (Sexton) on Apr 15, 2011 at 11:20 UTC
    Do you mean this?
    $t = new Net::Telnet(); $t->open("sparky"); $t->login( $username, $passwd ); $t->cmd( 'scp userb@serverb:/path/file userc@serverc:/dest/path' );
    If not, clarify please.