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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.