in reply to Unicode issues with emc uemcli

As an extra debugging step, could you please show the output of the following code?

use warnings; use strict; use Data::Dump; use IPC::Run3; run3 ['uemcli','-d',$vnxe_ip,'-u',$username,'-p',$password, '/sys/general','show','-detail'], undef, \my $out; dd $out;

Replies are listed 'Best First'.
Re^2: Unicode issues with emc uemcli
by pritesh_ugrankar (Monk) on Sep 07, 2020 at 19:08 UTC

    Hi Haukex,

    I get the following output. Please note. This time, I have not changed/modified the IP Address and the other information that was originally captured. I had earlier changed it in the output posted with the question for security purposes. Hope you understand. Thank you for your help and patience.

    "\xFF\xFES\0t\0o\0r\0a\0g\0e\0 \0s\0y\0s\0t\0e\0m\0 \0a\0d\0d\0r\0e\0s +\0s\0:\0 \x001\x000\0.\x001\x009\x006\0.\x001\x002\x004\0.\x006\x004\ +0\n\0S\0t\0 o\0r\0a\0g\0e\0 \0s\0y\0s\0t\0e\0m\0 \0p\0o\0r\0t\0:\0 \x004\x004\x003 +\0\n\0H\0T\0T\0P\0S\0 \0c\0o\0n\0n\0e\0c\0t\0i\0o\0n\0\n\0\n\x001\0:\ +0 \0 \0 \0 \0S\0y\0s\0t\0e\0m\0 \0n\0a\0m\0e\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0=\ +0 \0C\0D\0R\0-\0V\0N\0X\0e\x001\0\n\0 \0 \0 \0 \0 \0 \0M\0o\0d\0e\0l\ +0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0=\0 \0V\0N\0X\0e\x003\x003\x0 +00\x000\0\n\0 \0 \0 \0 \0 \0 \0P\0l\0a\0t\0f\0o\0r\0m\0 \0t\0y\0p\0e\ +0 \0 \0 \0 \0 \0 \0 \0 \0 \0=\0 \0E\0M\0C\0 \0S\0t\0o\0r\0a\0g\0e\0 \0S\0y\0s\0t\ +0e\0m\0\n\0 \0 \0 \0 \0 \0 \0P\0r\0o\0d\0u\0c\0t\0 \0s\0e\0r\0i\0a\0l +\0 \0n\0u\0 m\0b\0e\0r\0 \0=\0 \0A\0P\0M\x000\x000\x001\x001\x004\x007\x000\x000\x +008\x009\x004\0\n\0 \0 \0 \0 \0 \0 \0A\0u\0t\0o\0 \0f\0a\0i\0l\0b\0a\ +0c\0k\0 \0 \0 \0 \0 \0 \0 \0 \0 \0=\0 \0o\0n\0\n\0 \0 \0 \0 \0 \0 \0H\0e\0a\0l\0t +\0h\0 \0s\0t\0a\0t\0e\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0=\0 \0O\0K\0 \0( +\x005\0)\0\ n\0 \0 \0 \0 \0 \0 \0H\0e\0a\0l\0t\0h\0 \0d\0e\0t\0a\0i\0l\0s\0 \0 \0 +\0 \0 \0 \0 \0 \0=\0 \0\"\0T\0h\0e\0 \0s\0y\0s\0t\0e\0m\0 \0i\0s\0 \0 +o\0p\0e\0r\ 0a\0t\0i\0n\0g\0 \0n\0o\0r\0m\0a\0l\0l\0y\0.\0\"\0\n\0\n\0"

      That data is encoded with UTF-16LE. Although I'm not sure if there's a more elegant way to solve this because I'm not familiar with the "uemcli" command, by adding the following code to the example I posted above, you will get the properly decoded Perl string in $str.

      use Encode qw/decode/; my $str = decode('UTF-16', $out, Encode::FB_CROAK);

        Hi Haukex,

        All thanks to your clever code, I am finally able to capture the output to text files too!!. Here's the addition to your code.

        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', $pas +sword, '/env/bat', 'show', '-detail']; my $aref_cmd3 = ['uemcli', '-d', $vnxe_ip, '-u', $username, '-p', $pas +sword, '/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;

        Here, the cmd1 prints to screen, cmd2 can be output to a file. cmd3 I am yet to work on. Thank you once again..

        Hi Haukex,

        Yes, it works and perfectly shows the output!! Thank you so much.

        All I now how to figure out is how to put this my script so that I get the desired output. Quite frankly I'm not able to make much out of the clever stuff you wrote. You've wrapped the command in what I think is a anonymous aref along with undef, \my $out. Wish there were an easier way to do this, but , that is something for me to figure out. Thank you once again.