#!/usr/bin/env python

# Mike Zelazny
# Similar to caget, but for string waveforms

import sys
import subprocessca_R1_0_4 as subprocessca
import subprocess

try:
     value = subprocessca.get(sys.argv[1])
     v = ''
     found = 0
     next = 0
     m1 = ''
     m2 = ''
     for c in value:
          if m2 == chr(32) and m1 == chr(48) and c == chr(32): # " 0 " ends the string
               break
          if 1 == next:
               v += c
               next = 0
          if c == chr(39):
               if 0 == found:
                    found = 1 # found beginning quote
                    next = 1  # append next chargcter
               else:
                    found = 0 # found ending quote
          m2 = m1
          m1 = c
     print(v)
except ValueError as e:
     print sys.argv
     print('FAILED!\n')
