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
In reply to SCP connection by mantra2006
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |