Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

SFTP can use in SSH

by veeruch (Sexton)
on Jul 14, 2006 at 06:41 UTC ( [id://561160]=perlquestion: print w/replies, xml ) Need Help??

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

Thanks whom ever supported and Thanks to PerlMonks (Great PerlMonks)
I have few doubts ...while iam giving code given below. It is wroking fine ..

use Net::SSH::W32Perl; use Net::SFTP; my $ssh =ConnectSSH(); my($stdout, $stderr, $exit) = $ssh->cmd("ls"); my $sftp =ConnectSFTP(); $sftp->get("test.pl","C:/Documents and Settings/Administrator/Desktop/ +test.pl"); sub ConnectSSH { my $SSHObject = Net::SSH::W32Perl->new($host,use_pty => 0,debug=> +1); $SSHObject->login($user,$pass); return($SSHObject); } sub ConnectSFTP { my $SFTPOBJECT = Net::SFTP->new($host,(user => $user, password => +$pass,) ,debug=>1); return($SFTPOBJECT); }

My questions are :
1)Is it required to give two times Username,Password(SSH,SFTP function)?
2)Can we write SSH object for SFTP.. is it posslible?
3)how can i give command transfering binary or ascii in NET::SFTP?

Replies are listed 'Best First'.
Re: SFTP can use in SSH
by marto (Cardinal) on Jul 14, 2006 at 08:50 UTC
    veeruch,

    A lot of your recent questions are in this area, have you read the documentation for these modules properly?

    '2)Can we write SSH object for SFTP.. is it posslible?'

    Perhaps I am not understanding what you mean here, but did you read the documentation?

    'Net::SFTP is a pure-Perl implementation of the Secure File Transfer Protocol (SFTP) - file transfer built on top of the SSH2 protocol. Net::SFTP uses Net::SSH::Perl to build a secure, encrypted tunnel through which files can be transferred and managed.'

    '3)how can i give command transfering binary or ascii in NET::SFTP?'

    SFTP effectively uses binary mode for all transfers.

    Martin

      yes you told right ...how can i give ascii transfer bcoz if iam transfer in binary mode from windows machine to unix it is adding CTRL_M charters r adding for that wht i have do ...

      i can't use sftp->cmd for net sftp->cmd ,in that they have written Net::SSH::W32Perl wroking on SSH2 protocal SSH2 protocal supports multiple cmds.but here mycode not supporting

        The Ctrl-M chars don't get added during transfer, rather they are not stripped. Windows text file have CRLF line endings.

        To get rid of the Ctrl-M chars on a UNIX box, do:

        perl -pi -e 's/\r\n/\n/' filename

        You should adhere to the usage of the modules as layed out in their respective documentation.

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://561160]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2024-04-20 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found