# /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
#
####
# ./test.pl
testuser's New password: testpass
testpass
3004-657 Terminating from signal.
# echo $?
130
#
####
# ./test.pl
testuser's New password: testpass
testpass
Enter the new password again:
# echo $?
0
#
####
#!/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");
$| = 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;