Re: [Ssh-sftp-perl-users] Ssh-sftp-perl-users Digest, Vol 22, Issue 2
Brought to you by:
dbrobins
From: Rajnikant <raj...@pe...> - 2008-07-08 05:26:07
|
For authentication I used following work around. use Net::SFTP; my %args = ( "user", $usr, "password", $passwd, ); my $sftp = Net::SFTP->new($host_l,%args); Regards, Rajnikant. -----Original Message----- From: ssh...@li... [mailto:ssh...@li...] On Behalf Of ssh...@li... Sent: Monday, July 07, 2008 7:01 PM To: ssh...@li... Subject: Ssh-sftp-perl-users Digest, Vol 22, Issue 2 Send Ssh-sftp-perl-users mailing list submissions to ssh...@li... To subscribe or unsubscribe via the World Wide Web, visit https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users or, via email, send a message with subject or body 'help' to ssh...@li... You can reach the person managing the list at ssh...@li... When replying, please edit your Subject line so it is more specific than "Re: Contents of Ssh-sftp-perl-users digest..." Today's Topics: 1. Re: help needed for SFTP,SCP keys (Heiko Jansen) 2. Re: help needed for SFTP,SCP keys (Heiko Jansen) 3. About sftp->ls method (Rajnikant) 4. Re: About sftp->ls method (Heiko Jansen) 5. Unable to install Perl Module with cpan Repository on Linux (moh...@wi...) ---------------------------------------------------------------------- Message: 1 Date: Mon, 07 Jul 2008 09:37:35 +0200 From: Heiko Jansen <ja...@hb...> Subject: Re: [Ssh-sftp-perl-users] help needed for SFTP,SCP keys To: "ssh...@li..." <ssh...@li...> Message-ID: <121...@tr...> Content-Type: text/plain Am Montag, den 07.07.2008, 00:22 -0700 schrieb Vikas Poonia: > > I have one problem in Perl. I need to implement SFTP-Password, > SFTP-Keys,SCP-Password and Scp-Keys in Perl to transfer the file from > one system to another system. I have already implemented ftp and it is > working fine [...] > But for SFTP, SCP etc I am not able to find the function equivalent to > these like new,login,put etc. > does anyone have any sample code or 2-3 lines which explain all these. > I will be hoghly thankful to all of you. I am using > > use Net::SSH2; > > If have any idea about this please let me know. Thanks in Advance Just connect to the remote host with Net::SSH2 (using password or key) and then use the methods scp_get/scp_put of the Net::SSH2 object or retrieve an Net::SSH2::SFTP object by using the method call "sftp" on the Net::SSH2 object. It's all in the Net::SSH2 (or Net::SSH2::SFTP) documentation. The SYNOPSIS paragraph in Net::SSH2 POD even has a (shortened) example for SFTP transfer. Heiko ------------------------------ Message: 2 Date: Mon, 07 Jul 2008 13:06:53 +0200 From: "Heiko Jansen" <ja...@hb...> Subject: Re: [Ssh-sftp-perl-users] help needed for SFTP,SCP keys To: <ssh...@li...> Message-ID: <487...@ag...> Content-Type: text/plain; charset=US-ASCII Am Montag, den 07.07.2008, 02:01 -0700 schrieb Vikas Poonia: [...] > i am getting problem only when i try to connect. I am getting the > error 'unable to connect the remote host' for Scp-Keys my code looks > like > 1) my $ssh2 = Net::SSH2->new(); I really hope that there's a step 1a) $ssh2->connect($z_host) or die "Connecting $z_host failed"; > 2) $ssh2->auth_publickey("$z_user", "$publickey" , "$privatekey" ) or > die "Unable to login to user $z_user host $z_host $@ \n Login user > $z_user auf Host $@ nicht moeglich! \n"; Looks like some variables got mixed up. That error message should probably read -- snip -- die "Unable to login user $z_user on host $z_host: $@ \n Login user $z_user auf Host $z_host nicht moeglich! \n"; -- / snip -- But of course that can't be the source of the connection problems. > 3) $ssh2->scp_put(("$f_flam", "$f_ftp") or die "\nKonnte SST-Datei > $f_flam nicht nach $f_ftp versenden!\n\n"; > where $z_user is name of remote host I believe you meant "$z_host" here... > i m getting error on line nos 2 itself. > can u please suggest me something. do i need to change something in > place of $z_user etc. For any helpful advice you should provide more info on which error messages you get. Please turn on debug messages with "$ssh->debug(1);". You could also restart the ssh daemon on the server with a higher log level and have a look at the logfiles there if you believe that the problem source might be found there. Heiko ------------------------------ Message: 3 Date: Mon, 7 Jul 2008 17:29:22 +0530 From: "Rajnikant" <raj...@pe...> Subject: [Ssh-sftp-perl-users] About sftp->ls method To: <ssh...@li...> Message-ID: <006901c8e028$e5a81250$30c...@pe...> Content-Type: text/plain; charset="us-ascii" Hello everyone, I'm using sftp->ls method to see files on remote location. Following files are present on remote location: 5.txt, 4.txt, 3.txt, 2.txt, 1.txt Is there possibility that I'll get sftp->ls out put as 5.txt 4.txt -- -- 1.txt Can I have sorted sftp->ls out put? Out put I want is: 1.txt -- -- 4.txt 5.txt Thanks in advance. DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ Message: 4 Date: Mon, 07 Jul 2008 14:20:58 +0200 From: Heiko Jansen <ja...@hb...> Subject: Re: [Ssh-sftp-perl-users] About sftp->ls method To: "ssh...@li..." <ssh...@li...> Message-ID: <121...@tr...> Content-Type: text/plain Am Montag, den 07.07.2008, 17:29 +0530 schrieb Rajnikant: > > I'm using sftp->ls method to see files on remote location. Following > files are present on remote location: > 5.txt, 4.txt, 3.txt, 2.txt, 1.txt > > Is there possibility that I'll get sftp->ls out put as 5.txt 4.txt > -- > -- > 1.txt > > Can I have sorted sftp->ls out put? Out put I want is: > 1.txt > -- > -- > 4.txt > 5.txt As far as I know, $sftp->ls() (where $sftp IS_A Net::SFTP object) returns a list of hash references and there are no options of pre-sorting that list. But no one stops you from iterating over the list, extracting the names and sorting them in any way you like. So the answer to your questions is "yes" - but the way to get there is possibly not as convenient as you'd hoped ;-) Heiko PS: Another option would be to use do_opendir($path) and then use a readdir-loop directly on the dir handle, fetching all filenames and sorting them afterwards. PPS: Yet another method: Use Net::SSH2, execute a shell command ("ls" with the necessary switches) and capture and parse the output. ------------------------------ Message: 5 Date: Mon, 7 Jul 2008 19:00:42 +0530 From: <moh...@wi...> Subject: [Ssh-sftp-perl-users] Unable to install Perl Module with cpan Repository on Linux To: <ssh...@li...> Message-ID: <7A0...@BL...> Content-Type: text/plain; charset="us-ascii" Hi All, I want to install SSH module through cpan repository on linux, I am getting the following error. But I can install the modules manually by downloading the modules from cpan.org and using manual method. cpan> install Net::FTP Warning: Cannot install Net::FTP, don't know what it is. Try the command i /Net::FTP/ to find objects with matching identifiers. Please help me to overcome this. Thanks, Mustafa ________________________________ From: Mohammed Mustafa (WT01 - Testing Services) Sent: Wednesday, May 28, 2008 8:32 PM To: 'ssh...@li...' Subject: How to execute a perl script at remote server Hi All, I have written a Perl script, which deals with the ftp ing (transferring) the file to remote server and executing a Perl script (AUT) at remote m/c. The script is as below and here I have 2 doubts, so please help me to resolve this. 1) I am getting the message like "could not transfer the file to server" but it is ftp ing the flie to remote m/c, and I can see that file ( root1.txt ) there. 2) And I want to run the perl script (AUT) at remote m/c depending on the data we sent, so could you please let me know how can I achieve this. Is it possible for me to do system("test.pl"), If I am at SFTP mode. Please see comment line in the code below. #!/usr/bin/perl -w use strict; use warnings; use Net::SFTP; my $server="A.BY.C.D"; my $user="roserag"; my $password="june@123"; my %args = (user => "$user", password => "$password", ssh_args => []); $args{debug} = 1; $args{user} = "root"; my $file="local.txt"; my $rfile = "root1.txt"; my $sftp=Net::SFTP->new($server, %args) or die "could not open connection to $server\n"; $sftp->put($file,$rfile) or die " could not transfer the file to server \n"; # system("test.pl"); Is this command work out. exit; [gaurav@testbrix Examples]$ perl sftp3.pl testbrix.wipro.com: Reading configuration data /home/gaurav/.ssh/config testbrix.wipro.com: Reading configuration data /etc/ssh_config ................................... ................................... testbrix.wipro.com: sftp: In write loop, got 510 offset 0 testbrix.wipro.com: sftp: Sent message T:10 I:2 testbrix.wipro.com: sftp: Sent message T:4 I:3 could not transfer the file to server But I can see the file 1,1 All Regards, Mustafa -------------- next part -------------- An HTML attachment was scrubbed... ------------------------------ ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 ------------------------------ _______________________________________________ Ssh-sftp-perl-users mailing list Ssh...@li... https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users End of Ssh-sftp-perl-users Digest, Vol 22, Issue 2 ************************************************** DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. |