# Collection of code snippets by Arne Vajhøj 
# (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import sys,os
myFile = 'bin.txt'
if os.path.exists(myFile):
  with open(myFile,'r') as f:
    for line in f:
      print 'line = %s' % (line)
      myHead = hex(int(line[0:4],2))
      myID = hex(int(line[4:20],2))
      myCMD = hex(int(line[20:24],2))
      myCMD = hex(int(line[20:24],2))[2:]
      myCMD = hex(int(line[20:24],2)).lstrip('0x')
      print 'myHead = %s' % (myHead)
      print 'myID = %s' % (myID)
      print 'myCMD = %s' % (myCMD)
