1826063 Members
3891 Online
109690 Solutions
New Discussion

Hex Conversion

 
SOLVED
Go to solution
Nobody's Hero
Valued Contributor

Hex Conversion

Can someone tell me how to convert this ?

(device 0x1f006000)

Is this in hex?
How do I convert it, I've been out of school for quite a while.
UNIX IS GOOD
4 REPLIES 4
Nobody's Hero
Valued Contributor

Re: Hex Conversion

I have syslog filling with failed disk messages:

vmunix: LVM: Recovered Path (device 0x1f006000) to PV 0 in VG 0.
Dec 8 08:27:19 ihshp4 vmunix: SCSI: Write error -- dev: b 31 0x006000, errno: 126, resid: 1024,
Dec 8 08:27:18 ihshp4 vmunix: LVM: Recovered Path (device 0x1f006000) to PV 0 in VG 0.
Dec 8 08:27:19 ihshp4 vmunix: blkno: 3191299, sectno: 6382598, offset: -1027077120, bcount: 1024.
Dec 8 08:27:18 ihshp4 vmunix: LVM: Restored PV 0 to VG 0.

UNIX IS GOOD
Oskar Ahner
Occasional Advisor

Re: Hex Conversion

Convert to what? I assume decimal?
In that case just do:

0*16^0 + 0*16^1 + 0*16^2 + 6*16^3 + 0*16^4 + 0*16^5 + 15*16^6 + 1*16^7

/Oskar
RAC_1
Honored Contributor
Solution

Re: Hex Conversion

0x1f006000 - The 0x indicates that is a hex no.

The simplest way to know which is associated device
ll /dev/dsk/* | grep 006000

Else, decode it as follows.
1f - printf "%d\n" 0x1f
will give 31
/usr/sbin/lsdev -b 31
Character Block Driver Class
188 31 sdisk disk

This is a disk device
00600
c0t6d0

Hope this helps.
Anil
There is no substitute to HARDWORK
Ron Thompson
Advisor

Re: Hex Conversion

#!/bin/ksh
#convert the 8 character hex input string to decimal and output in device name format of c#t#d#
#found this in the HP itrc, usefull for decoding dmesg and syslog error entries
#sample use:
# scsi_decoder a12b3c44
# This translates to c43t3d12

Z=$1 #save input argument to $Z

#translate $Z to all upper case and save in $I
I=`echo $Z|tr '[a-z]' '[A-Z]'`

#get the length of the string in characters and save in $LENGTH_I
LENGTH_I=`echo $I|wc -m`

#if the input string is the correct length
if test "$LENGTH_I" -eq 9
then
#remove the first two characters of $I and save to $A
A=`echo $I|sed s/..//`

#now remove the last 4 characters of $A
#saving only the 3rd and 4th characters into $B
B=`echo $A|sed s/....$//`

#convert hex $B to decimal and save in $C
C=`echo "ibase=16;$B"|bc`

#remove first 4 characters
R=`echo $I|sed s/....//`
#and remove last 3 and save in $S
S=`echo $R|sed s/...$//`
#and convert hex $S to decimal and save in $T
T=`echo "ibase=16;$S"|bc`

#remove first 5 characters
F=`echo $I|sed s/.....//`
#and remove last two characters and save in $G
G=`echo $F|sed s/..$//`
#convert hex $G to decimal and save in $D
D=`echo "ibase=16;$G"|bc`

#send output to user in format of c#t#d#
echo "This translates to c"$C"t"$T"d"$D" "
echo
else
#tell the user if not the correct length
echo "The input string must be exactly 8 bytes. "
fi