# su -root -c 'command' Password: #### my $t = Net::Telnet->new( -host => $ip , -timeout => 60, -errmode => "return"); do{ print qq{Failed open Telnet Session for '$host' }; exit 1; } unless ( $t ); $t->login( $user,$passwd ); do { print qq{Login Failed for '$host'} ; exit 1 } if ( $t->errmsg ); my $cmd1 = "\$OMNIHOME/bin/nco_ping NCO_PA "; my @out1 = $t->cmd(String => $cmd1, Timeout => 10 ); print " Out ==> @out1 \n"; my $exp = Expect->exp_init($t); $timeout = 3; $exp->expect($timeout, [ 'Password: $', sub { my $fh = shift; print $fh "$password\n"; exp_continue; } ], ); #my $cmd2 = "su root -c ls ";