mantra2006 has asked for the wisdom of the Perl Monks concerning the following question:
hello
I was using the following script to connect to remote host and copy a file. The script actually copies the file. But when I run the script it asks me password for remote host. Is there a way to automate so that the script won't ask for password and everything copy when the script is run
use::warnings; use::strict; my $rmthost = 'backupserver'; my $rmtuser = 'anonymous'; my $rmtpath = 'tempdir'; my $lclpath = '/home/user/testdir'; my $lclglob = '*.txt'; my $flagfile = '.last_backup'; my $r_opts = "'ssh -l $rmthost $rmtuser'"; my $lclfiles = "$lclpath/$lclglob"; sub modtime { my $file = shift; my @stats = stat $file or return 0; return $stats[9]; } while (1) { my $timestamp = modtime("$lclpath/$flagfile"); my $run = grep {modtime($_) > $timestamp} glob $lclfiles; if ($run) { system "scp $r_opts $lclfiles $rmthost:$rmtpath"; open FLAG, ">$lclpath/$flagfile" or die; close FLAG or die; } sleep 60; }
20060724 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
Considered by Hue-Bond: Mark as OT, since this isn't strictly a Perl question
Unconsidered by Arunbear: Keep: 24, Edit: 19, Reap: 2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SCP connection
by Joost (Canon) on Jul 24, 2006 at 18:42 UTC | |
|
Re: SCP connection
by ikegami (Patriarch) on Jul 24, 2006 at 18:51 UTC | |
|
Re: SCP connection
by madbombX (Hermit) on Jul 24, 2006 at 18:53 UTC | |
by rodion (Chaplain) on Jul 24, 2006 at 20:36 UTC | |
by mantra2006 (Hermit) on Jul 24, 2006 at 20:00 UTC | |
by Joost (Canon) on Jul 24, 2006 at 20:48 UTC | |
by mantra2006 (Hermit) on Jul 25, 2006 at 18:29 UTC | |
by Joost (Canon) on Jul 25, 2006 at 20:49 UTC | |
|
Re: SCP connection
by superfrink (Curate) on Jul 24, 2006 at 19:17 UTC |