title: How to convert decimal to hex and send hex using expect(TCL) script
body: <p>I am writing a small expect(TCL) script to send a series of numbers in hex format and expect something. I am iterating over a loop to send the bytes one by one. but I am not able to send the number in hex form. </p>
  
  <p>Below is a sample code. I need to send the first line over a loop with numbers in 0x form. second line is something I tried out.</p>
  
  <pre><code>send "show hardware internal qengine inst 0 memory ib_rr0_span_dc3hdr start 0x0 num 0x2 \r"
  expect "#"
  
  for {set i 0} {$i &lt; 16} {incr i 1} {
  puts stdout "i val: $i '\x$i'"
  
  }
  </code></pre>