0

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.

3
  • your script is probably waiting on the readline() because there is no \n on stdin. Commented Apr 28, 2013 at 16:33
  • @Chronial No it's not because I'm able to update the database after the print statement, its probably printing somewhere else than terminal. I don't know why Commented Apr 28, 2013 at 16:34
  • @Chronial Also after scanfun() ends the while loop enters again and print "------Parking Sector 11----------" is being displayed, only what is inside the scanfun() is not being displayed. Commented Apr 28, 2013 at 16:38

1 Answer 1

2

So your k.sh runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, which then runs k.sh, which then runs parking-mng.py, ...

Infinite recursion much?

Sign up to request clarification or add additional context in comments.

1 Comment

I guess I never pondered over this! :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.