0

when I enter a command in command line, I got the output like below. wanted to write a python program which will take the first line's only hex values as input (31 2e 30 38 2e 32 30 32 31 30 38 32 35 00 00 00) and convert to ASCII string.

$> set system cmd -i 33 -c raw 0x38 0x0b 0x06 -- command 

    Ipmi Response: 31 2e 30 38 2e 32 30 32 31 30 38 32 35 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   Completion Code: Success

Tried this:

hex_str = "31 2e 30 38 2e 32 30 32 31 30 38 32 35 00 00 00"
string = ''.join(chr(int(i, 16)) for i in hex_str.split()) 

but not sure how to remove the "Ipmi response: " part from the string.

Phydeaux
  • 2,795
  • 3
  • 17
  • 35
jpb38
  • 1
  • Use a slice. `hex_str = main_str[len('Ipmi Response: '):]` – 2ps Oct 12 '21 at 12:48
  • 1
    Does this answer your question? [Remove a prefix from a string](https://stackoverflow.com/questions/16891340/remove-a-prefix-from-a-string) – Phydeaux Oct 12 '21 at 12:49
  • its not about remove the prefix, but python program to take the command output's first line as input and convert the hex values to ascii string – jpb38 Oct 12 '21 at 13:15

0 Answers0