there has to be a problem with how i am passing the password to my expect object, i know that i have the correct password (just reset it) . i keep getting a authentication failed error from su. what have i missed?
#!/usr/local/bin/perl -w use strict; use Expect; my $username = $ARGV[0]; my $password = $ARGV[1]; my $on_off = $ARGV[2]; my $message; my $set_fwd; my $timeout = 15; my $exp = new Expect; my $FILENAME; my @list_of_files; @list_of_files=(".forward", ".vacation.msg", ".vacation.pag", ".vacati +on.dir"); if($#ARGV > 2) { $message = join (" ",@ARGV); $message =~ s/$username//; $message =~ s/$password//; $message =~ s/$on_off//; } ####################################### print $username; print "\n"; print $password; print "\n"; print $on_off; print "\n"; print $message; print "\n#######################################\n"; ####################################### $exp->raw_pty(1); $exp->spawn("su - $username") or die "Cannot Begin Login Process\n";; $exp->expect($timeout, [ 'assword', sub { $exp->send("$password"); exp_continue; } ], [ '-re', qr'[#>:%] $', sub { if($on_off eq "on") { foreach $FILENAME (@list_of_files) { $exp->send("/bin/touch /home/$username/$FILENAME"); if ( $FILENAME eq ".forward") { #.forward must look like \username, "|/usr/bin/ +vacation username" $set_fwd="\\$username, \"|/usr/bin/vacation $usern +ame\""; $exp->send("/bin/echo $set_fwd > /home/$username/$ +FILENAME"); } if ( $FILENAME eq ".vacation.msg") { $message .= '\n'; $exp->send("/bin/echo $message > /home/$username/$ +FILENAME"); } $exp->send("/bin/chmod 644 /home/$username/$FILENAME" +); $exp->send("/bin/chown $username /home/$username/$FIL +ENAME"); } if($on_off eq "off") { foreach $FILENAME (@list_of_files) { $exp->send("/bin/rm -f /home/$username/$FILENAME"); } } exp_continue; } } ], [ timeout => sub { print "Process Timed Out.\n"; } ] );
anyone know what to do to fix this?

In reply to Expect module & su by jcpunk

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.