Operating System - HP-UX
1830044 Members
5618 Online
109998 Solutions
New Discussion

Anyone know an equivalent to HP-UX vis command in Solaris?

 
SOLVED
Go to solution
Jason Berendsen
Regular Advisor

Anyone know an equivalent to HP-UX vis command in Solaris?

My DBA has asked me to parse a file on a Solaris box. The problem I am running into is the file he want's me to work with has embedded null characters (\000) in it. He wants me to replace these null characters with spaces. This can easily be accomplished by using sed and vis on the HP-UX servers, but I can't find an equivalent to vis in Solaris. I have tried using tr but it won't replace each null character with a space. Does anyone know of an equivalent command to vis in Solaris???
11 REPLIES 11
Ranjith_5
Honored Contributor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?

Hi Jason,

Attached the excel sheet.includes equivqlent commands in Linux,hp,solaris and AIX.


regards
Syam
Hein van den Heuvel
Honored Contributor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?


Sounds like a Solaris buglette. Ask Sun for a fix?!

Or use PERL as that is most likely to be equal / similar.

If you describe the file in detail, or attach a fraction, maybe a read can help with the transformation (allhough most readers probably have a hard time trying on a Sun box).

for generic HPUX - vs - Solaris - vs - other-unix commands (like the title suggesed to me) be sure to check out:

http://bhami.com/rosetta.html

Hein.
Ranjith_5
Honored Contributor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?

Hi Jason,

I tried and it worked in my solaris machine.

This is what I used.

#sed -e 's/\\(000)/ /g' < filename > new_file

only replace "filename" as applicable. The dont repace < and > characters.

This replaced the null characters with a space in my machine.Reply with your observations.

Regards,
Syam

harry d brown jr
Honored Contributor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?


on HP box:

mknod /tmp/send_it_back p
remsh SUNboxname dd if=thatDBAfilename | vis > /tmp/send_it_back

on solaris box:

rsh HPbox dd if=/tmp/send_it_back | dd of=aNEWDBAfile

to UN-vis it (aka inv) just change the command and filenames:


on HP box:

remsh SUNboxname dd if=aNEWDBAfile | inv > /tmp/send_it_back

on solaris box:

rsh HPbox dd if=/tmp/send_it_back | dd of=aNEWerDBAfile


example of a tar file:

[root@HPBOX /tmp]# remsh pbsbcp dd if=/tmp/craze.tar | vis > /tmp/send_it_back
1360+0 records in
1360+0 records out


[root@SUNBOX /tmp]# uname -a
SunOS SUNBOXp 5.7 Generic_106541-23 sun4u sparc SUNW,Ultra-5_10
[root@SUNBOX /tmp]# ls -l craze.tar
-rw-r--r-- 1 root other 696320 Feb 7 08:17 craze.tar
[root@SUNBOX /tmp]# rsh vpart1 dd if=/tmp/send_it_back | dd of=/tmp/acraze.tar
1729+1 records in
1729+1 records out
1729+1 records in
1729+1 records out

then BACK again:

[root@HPBOX /tmp]# remsh pbsbcp dd if=/tmp/acraze.tar | inv > /tmp/send_it_back
1729+1 records in
1729+1 records out

[root@SUNBOX /tmp]# rsh vpart1 dd if=/tmp/send_it_back | dd of=/tmp/new_acraze.tar
1360+0 records in
1360+0 records out
1360+0 records in
1360+0 records out
[root@SUNBOX /tmp]# ls -l *craze.tar
-rw-r--r-- 1 root other 885375 Feb 7 14:00 acraze.tar
-rw-r--r-- 1 root other 696320 Feb 7 08:17 craze.tar
-rw-r--r-- 1 root other 696320 Feb 7 14:01 new_acraze.tar


live free or die
harry d brown jr
Live Free or Die
harry d brown jr
Honored Contributor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?


It's not a bug of solaris, though solaris does lack features and functionality. I'm not aware of any similar solaris command for vis/inv (see man pages for inv or vis).

inv and vis are HP developed utilities. The same can be written in most languages, though perl would work fine, c would be faster.

live free or die
harry d brown jr
Live Free or Die
Ranjith_5
Honored Contributor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?

Jason ,

Here are some examples for find and replace using perl.

go to topic 7. Substitution

regards,
Syam
Ranjith_5
Honored Contributor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?

Jason Berendsen
Regular Advisor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?

Syam, I tried your sed syntax and it didn't replace the null characters with spaces.

Here is an example of what I see in the middle of the line when I use HP-UX /usr/bin/vis:
425\000\000\000\000\000\00004042

The \000 denote null characters. Once again in HP it is easy to replace these but there doesn't seem to be an equivalent functionality in Solaris. I may need to go with Harry's suggestion to code it myself in Perl. In case anyone has any ideas I have attached a single line of the file that has the null characters in it. Again I want to keep the character count the same by replacing the null characters with spaces.
Hein van den Heuvel
Honored Contributor
Solution

Re: Anyone know an equivalent to HP-UX vis command in Solaris?


This seems to work for me.. on Tru64:

perl -pe 's/\000/ /g' file-with-null > file-with-spaces

hth,
Hein.
harry d brown jr
Honored Contributor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?

Jason,

b2a.pl:
#!/usr/bin/perl
#
while (!eof()) {
$key = getc(STDIN);
$num = ord($key);
if (($num > 31) && ($num < 127)) {
if ($num == 92) {
printf("\\%03d",$num);
} else {
printf("%s",$key);
}
} else {
if ($num == 10) {
printf("\n");
} else {
printf("\\%03d",$num);
}
}
}


a2b.pl:
#!/usr/bin/perl
#
while (!eof()) {
$key = getc(STDIN);
$num = ord($key);
if ($num == 92) {
$val1 = getc(STDIN);
$val2 = getc(STDIN);
$val3 = getc(STDIN);
$key = $val1 . $val2 . $val3;
$newkey = chr($key);
$key = $newkey;
}
printf("%s",$key);
}

Sorry about the no comments. 92=\ I especially escape this out to \###. I leave NL's (newlines) alone. any non-printing character is escapeed to \###, where ### is the ascii DECIMAL value (man ascii).

Of course this can be VERY cleaned up and made more efficient!

live free or die
harry d brown jr
Live Free or Die
Jason Berendsen
Regular Advisor

Re: Anyone know an equivalent to HP-UX vis command in Solaris?

Thanks for all the help. I was able to utilize your suggestions in Perl to get what I needed.