my $aref_cmd1= ['uemcli','-d',$vnxe_ip,'-u',$username,'-p',$password, '/sys/general','show','-detail']; my $aref_cmd2 = ['uemcli', '-d', $vnxe_ip, '-u', $username, '-p', $password, '/env/bat', 'show', '-detail']; my $aref_cmd3 = ['uemcli', '-d', $vnxe_ip, '-u', $username, '-p', $password, '/env/ps', 'show', '-detail']; run3 $aref_cmd1, undef, \my $out1; run3 $aref_cmd2, undef, \my $out2; run3 $aref_cmd3, undef, \my $out3; use Encode qw/decode/; my $str1 = decode('UTF-16', $out1, Encode::FB_CROAK); print "$str1\n"; my $textfile2 = "textfile2.txt"; open (my $fh2, '+>', $textfile2) or die "Cannot open file.$!"; my $str2 = decode('UTF-16', $out2, Encode::FB_CROAK); print $fh2 $str2;