Unix Shell - NEWB NEEDS HELP: rsync and ssh and PERL

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > October 2007 > NEWB NEEDS HELP: rsync and ssh and PERL





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author NEWB NEEDS HELP: rsync and ssh and PERL
RocketMan

2007-10-12, 7:24 pm

Sorry, I am very new and I can't find any examples of what I want to
do.

I am trying to write a command in a PERL script that will take either
the file or the directory I give it and send it to another server via
ssh. I believe that the ssh part of this command would prompt the
user for name/password if there isn't a key already on the other
server which is what I want to happen.

Here is what I have so far (in PERL)
system("rsync -nre --rsh=\"ssh $destHost \" $localFile $remoteDir");

which should end up as:
rsync -nre --rsh="ssh Host" file remoteDir

Since they haven't set me up yet to test this, I wanted to make sure
that:
1) this will work with both files and directories in the 'file'
position.
2) this will check for a key and if there is not one, prompt for user
name and password.
3) this will actually WORK!?

I read the man page and am confused since I see a -l switch for ssh
and I may or may not know the username in this script.

Please let me know what you think

THANKS

Bill Marcum

2007-10-12, 7:24 pm

On 2007-10-12, RocketMan <ImaChessNut@gmail.com> wrote:
>
> I read the man page and am confused since I see a -l switch for ssh
> and I may or may not know the username in this script.
>

If you don't specify the username, and it isn't given in ~/.ssh/config, ssh
assumes that the remote username is the same as the local one.

RocketMan

2007-10-15, 7:22 pm

On Oct 12, 2:55 pm, Bill Marcum <marcumb...@bellsouth.net> wrote:
> On 2007-10-12, RocketMan <ImaChess...@gmail.com> wrote:
>
>
> If you don't specify the username, and it isn't given in ~/.ssh/config, ssh
> assumes that the remote username is the same as the local one.


so lets say that the username does not exist on the remote
machine...will they be prompted for username / password?

Jim Jackson

2007-10-18, 7:22 pm

RocketMan <ImaChessNut@gmail.com> wrote:
> Sorry, I am very new and I can't find any examples of what I want to
> do.


> I am trying to write a command in a PERL script that will take either
> the file or the directory I give it and send it to another server via
> ssh. I believe that the ssh part of this command would prompt the
> user for name/password if there isn't a key already on the other
> server which is what I want to happen.


> Here is what I have so far (in PERL)
> system("rsync -nre --rsh=\"ssh $destHost \" $localFile $remoteDir");


But rsync won't use the ssh because the destination is a simple directory
spec. It should be

system("rsync -nre --rsh=ssh $localFile $destHost:$remoteDir");

please read the rsync manual again.

> which should end up as:
> rsync -nre --rsh="ssh Host" file remoteDir


> Since they haven't set me up yet to test this, I wanted to make sure
> that:
> 1) this will work with both files and directories in the 'file'
> position.
> 2) this will check for a key and if there is not one, prompt for user
> name and password.
> 3) this will actually WORK!?


> I read the man page and am confused since I see a -l switch for ssh
> and I may or may not know the username in this script.


> Please let me know what you think


> THANKS


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com