I'm using zbarcam to read barcodes, since zbarcam doesn't terminate automatically after reading a code.
Here's my parking-mng.py file:
#!/usr/bin/python import subprocess import MySQLdb as db from config import * import sys temp = '' def scanfun(): subprocess.call("./k.sh") reg = sys.stdin.readline().strip() con = None con = mdb.connect(server, user, pwd, database); cur = con.cursor() print "successful" while(1): print "------Parking Sector 11----------" print "Select : " print """1. Scan Code\n2. Update Balance\n3. Exit\n""" choice = raw_input() if choice == '1': scanfun() else: break Here's my k.sh file:
#!/bin/bash tmp=/tmp/barcode.$$ zbarcam --raw /dev/video1 > $tmp & pid=$! # Sleep until file has content while [[ ! -s $tmp ]] ; do sleep 1 done kill $pid cat $tmp | ./parking-mng.py The problem is that the print statement is not working, nothing is getting printed on the terminal.
\non stdin.scanfun()ends the while loop enters again andprint "------Parking Sector 11----------"is being displayed, only what is inside the scanfun() is not being displayed.