终端AREN'在重新启动脚本中打开
我的总体目的是要有一个进行条形码扫描的程序,如果在给定的时间后没有条形码扫描,则杀死程序并重新启动程序。现在,我试图在给定时间后重新启动该程序,但是它没有重新启动,而是杀死了该程序,而从未启动该程序。
我猜想这个问题是在 barcoderestart.sh 脚本和 startTimer.py 脚本之间,因为到目前为止,其他所有内容都按预期工作。
我已经包含了所有代码,以防万一其他有关
我有一个重新启动脚本来杀死终端并重新运行程序: 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
它运行 barcodetest.sh 脚本:
#!/bin/bash
cd /home/nvidia/local_orch/utilities
python3 ./barcodetest.py
barcodetest.py 脚本:
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")
一旦我扫描部分,它就会启动 timer.sh 脚本:
#!/bin/bash
cd /home/nvidia/local_orch/utilities
python3 ./starttimer.py
它启动 startimer.py ,在给定时间之后,它应该重新启动程序。
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")
但是,当它到达时间的尽头时,它只是杀死了程序,从不重新启动
barcodeTest.sh 脚本。它没有给我任何错误代码。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论