Specifically, I am trying to push the password to ssh-copy-id program, as it doesn't have a parameter, that I can use to feed the password noninteractively.
I've tried:
#These two just exit after this command $result = `ssh-copy-id -i $path_publick_key $user\@$server 2>/dev/null + < "$password"`; $result = `ssh-copy-id -i $path_publick_key $user\@$server 2>/dev/null + < "$password\n"`; #This gives a password prompt, without me printing the $result, which +makes me think, that ssh is using some named output device, instead o +f stdout. #$result is empty: $result = `echo "$password"|ssh-copy-id -i $path_publick_key $user\@$s +erver 2>/dev/null`;
use IPC::Cmd qw{run}; $ssh_cp_id = ''; $ssh_cp_id_result = run( 'command'=>"ssh-copy-id -i $path_pk $user\@$server 2>/dev/null", 'buffer'=>\$ssh_cp_id ); if($ssh_cp_id_result){ #print has no effect, as the password prompt got already displayed + without being captured to the $ssh_cp_id: print $ssh_cp_id; }
I can't figure out how to do it. I need to use only standard modules or no modules at all, as our organization policy requires. I was already thinking about 'expect' cli program, it's not installed by standard on the system and the 'Expect' perl module, also nonstandard, so can't use them.

In reply to I am having a big difficulty with two way pipes from a system executed command by igoryonya

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.