I hate to say "it depends", but "it depends".

For somethings, you can experiment around with echoing to the command. For example:
system("echo $password | foo -args file");
Some commands will allow you to put usernames/passwords in files and use those files as input. For example:
system("foo -args file < passwordfile");
You may also be able to use perl to do some of this echoing. For example:
open(FOO,"| foo -args file"); print FOO "username\n"; print FOO "password\n"; close(FOO);
You may also want to look into IPC::open2. This allows you to write to a program as well as get information from it.

Finally, you may want to look at the Expect module. This allows you to wait on a particular prompt to which you can respond.

Hopefully, one of the solutions above (or a combination thereof) will help you out. Good luck.

Hope that helps,
Shendal

Update: The above is meant as quick example only. You will, of course, want to do some checking on your system calls before launching any programs, as KM points out in his well-crafted example below.

In reply to Re: passwords and system calls by Shendal
in thread passwords and system calls by Anonymous Monk

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.