CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
SCP a folder from local machine to remote machine...!

 



autoworld
Novice

Aug 29, 2010, 1:24 AM

Post #1 of 5 (3700 views)
SCP a folder from local machine to remote machine...! Can't Post

Hi all,

I am trying fo automate few test cases. I need to send a folder to a remote system using SCP. I have done ssh to the remote machine and passed scp as shell command. I am finding it tough to give password for the scp.. Please help...



#!/usr/bin/perl

use Net::SSH::Perl;

my $host = "192.168.200.254";
my $user = "root";
my $password = "root";




#-- set up a new connection
my $ssh = Net::SSH::Perl->new($host);
#-- authenticate
sleep(3);
$ssh->login($user, $password);
sleep(2);

#need to enter password after scp. please help...!
$ssh->cmd("scp -r user@192.168.200.165:/home/user/1020_exe 1020_exe");

sleep (5);

$ssh->cmd("cd 1020_exe");
sleep(1);

$ssh->cmd("chmod 777 *");
sleep(1);


$ssh->cmd("./hello");
sleep(1);


(This post was edited by autoworld on Aug 29, 2010, 1:31 AM)


FishMonger
Veteran / Moderator

Aug 29, 2010, 8:46 AM

Post #2 of 5 (3684 views)
Re: [autoworld] SCP a folder from local machine to remote machine...! [In reply to] Can't Post

The best approach would be to use ssh key exchange instead of passing the credentials in the script. However, based on your other post, you've decided to use Expect.

Why do you have all of those unnecessary sleep commands?


autoworld
Novice

Aug 29, 2010, 6:08 PM

Post #3 of 5 (3666 views)
Re: [FishMonger] SCP a folder from local machine to remote machine...! [In reply to] Can't Post

Hi,

Thank you for your help. i decided to use password beacuse I am login into a processor, where all the files will get deleted after reboot. So that public key should be passed each time. I ll remove those sleeps.


autoworld
Novice

Aug 31, 2010, 11:09 PM

Post #4 of 5 (3514 views)
Re: [FishMonger] SCP a folder from local machine to remote machine...! [In reply to] Can't Post

Hi,

I want to create a user in remote machine using ssh. Please help me in giving the password after adduser command. I need to wait for the prompt "New password:" .


#!/usr/bin/perl

use Net::SSH::Perl;

my $host = "192.168.200.254";
my $user = "root";
my $password = "root";

#-- set up a new connection
my $ssh = Net::SSH::Perl->new($host);
#-- authenticate
sleep(3);
$ssh->login($user, $password);
sleep(2);
$ssh->cmd("adduser thomas");
sleep(1);
$ssh->print("thomas123"); #wrong method
sleep(4);
$ssh->print("thomas123"); #wrong method


FishMonger
Veteran / Moderator

Sep 1, 2010, 5:00 AM

Post #5 of 5 (3504 views)
Re: [autoworld] SCP a folder from local machine to remote machine...! [In reply to] Can't Post

Use the -p switch and specify the encrypted password in the adduser command.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives