Daniel
Daniel

Reputation: 1

terminals aren't opening in restart script

My overall objective is to have a program that takes in barcode scans and if after a given period of time there is no barcode scan then kill the programs and restart it. right now I'm trying to get the program to restart after a given period of time, but instead of rebooting, it just kills the program and never boots it up.

I'm guessing the issue is between the barcoderestart.sh script and the starttimer.py script as thus far everything else works as expected.

I have included all the code in case there is anything else concerning

I have a restart script that kills the terminals and reruns the programs: barcoderestart.sh:

#!/bin/bash
     
pkill -f lxterminal 
sleep 1 
pkill -f lxterminal 
sync 
sleep 5 
export DISPLAY=:0.0
    
lxterminal -e /home/nvidia/local_orch/utilities/barcodetest.sh & 
sleep 5

It then runs barcodetest.sh script:

#!/bin/bash

cd /home/nvidia/local_orch/utilities

python3 ./barcodetest.py

barcodetest.py script:

def writeLog(l):
    lt = time.localtime(time.time())
    global insstarttime
    insstarttime = lt
    lt2 = str(lt[0])+"-"+str(lt[1])+"-"+str(lt[2])+"-"+str(lt[3])+"."+str(lt[4])+"."+str(lt[5])
    lg = lt2+" : "+l
    with open('barcodetest.txt','a') as lfile:
        lfile.write(lg+"\n")
        print(lg)
    return 0
    
    while not stopped:
        mins, secs = divmod(t, 60)
        timer = '{:02d}:{:02d}'.format(mins, secs)
        print(timer, end="\r")
        time.sleep(1)
        t -= 1
      
    print('Fire in the hole!!')

while True:
    lt = time.localtime(time.time())
    rawscan = ''
    while sys.stdin in select.select([sys.stdin],[],[],0)[0]:
        input0 = sys.stdin.readline()
        if input0:
            rawscan = input0.rstrip()
            PN = rawscan[0:7]
            serial = rawscan[8:]
            serial = serial.strip()


            print("Part number is "+PN)
            print("serial is "+ serial)
            writeLog("RAW Scan is "+rawscan)
            os.system("lxterminal -e /home/nvidia/local_orch/utilities/timer.sh")

As soon as I scan part it starts the timer.sh script:

#!/bin/bash

cd /home/nvidia/local_orch/utilities

python3 ./starttimer.py

It starts the startimer.py and after a given time it should restart the program.

def countdown(t):
 while t:
        mins, secs = divmod(t, 60)
        timer = '{:02d}:{:02d}'.format(mins, secs)
        print(timer, end="\r")
        time.sleep(1)
        t -= 1
      
    print('Fire in the hole!!')
countdown(int(5))
time.sleep(1)
os.system("/home/nvidia/local_orch/utilities/barcoderestart.sh") 

however when it reaches the end of the time, it just kills the programs and never reboots

barcodetest.sh script. It isn't giving me any error codes.

Upvotes: 0

Views: 36

Answers (0)

Related Questions