Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Fellow Monks!

I'm working on this for over 2 days now to no avail, and I must admit IPC is one of my weakest fields. I have got the task to automate resetting passwords without user input on AIX /w HACMP. Although I'm allowed to test as root user, I'm not allowed to install any modules like Expect.

When I run the external command over the command line, I type in the passwords which get not displayed and all is OK:

# /usr/es/sbin/cluster/sbin/cl_chpasswd -cspoc -f -k testuser Changing password for "testuser" testuser's New password: Enter the new password again: # echo $? 0 #

When run by my test script and hitting <Ctrl+C> after the second password display:

# ./test.pl testuser's New password: testpass testpass 3004-657 Terminating from signal. # echo $? 130 #

When run by my test script and typing in the password followed by <ENTER> after second password display:

# ./test.pl testuser's New password: testpass testpass Enter the new password again: # echo $? 0 #

So I can see the passwords get printed but the external program doesn't get the input.
Any ideas?
Thanks in advance!
Below my test script:

#!/usr/bin/perl use strict; use warnings; $ENV{ODMDIR} = '/etc/objrepos/'; # needed for external program my $user = 'testuser'; my $password = 'testpass'; my $cmd = "/usr/es/sbin/cluster/sbin/cl_chpasswd -cspoc -f -k $user"; #print $cmd, $/x2; # verified - OK use IPC::Open2; my $pid = open2(*Reader, *Writer, $cmd); # No success with following variations: #my $pid = open2(*Reader, *Writer, "$cmd </dev/tty"); #my $pid = open2(*Reader, *Writer, "$cmd </dev/tty >/dev/tty"); $| = 1; # Verify device: #use POSIX; #my $tty = POSIX::ctermid(); #print "\nTTY: '$tty'\n\n"; # prints: TTY: '/dev/tty' local *STDOUT; open( STDOUT, ">>/dev/tty" ); # wait until external program is ready sleep 5; # Enter password: #print Writer "$password\n"; # neither displayed nor accepted as input print "$password\n"; # will be displayed but not accepted as input sleep 2; # Repeat password: #print Writer "$password\n"; print "$password\n"; waitpid $pid, 0; close Reader; close Writer;


In reply to Submitting password changes to external program by Dietz

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-24 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found