我使用-wait-event-and-download參數運行gphoto,以便使用我的紅外遙控器拍攝的照片保存到計算機中。獲取gphoto2的當前狀態
我有第二個腳本設置中斷等待處理,並拍照編程,就像這樣:
#!/bin/sh
# shootnow.sh - stop the current gphoto2 process (if it exists),
# shoot a new image, then start a new wait-event process.
pkill -INT gphoto2 #send interrupt (i.e. ctrl+c) to gphoto2
sleep 0.1 #avoid the process ownership error
gphoto2 --capture-image-and-download #take a picture now
gphoto2 --wait-event-and-download #start a new wait-event process
但我想,以確保第一等待事件處理當前沒有下載的圖像在我中斷它之前(這會導致圖像填滿相機的內存,妨礙進一步操作)的混亂情況。所以第二個腳本應該是更像這樣的東西:
#!/bin/sh
# shootnow-with-check.sh - stop the current gphoto2 process (if it exists
# and isn't currently downloading an image), shoot a new image, then start
# a new wait-event process.
shootnow() { # same as previously, but now in a function
pkill -INT gphoto2
sleep 0.1
gphoto2 --capture-image-and-download
gphoto2 --wait-event-and-download
}
if [ ***current output line of gphoto2 process doesnt start with "Downloading"*** ] then
shootnow
else
echo "Capture aborted - a picture was just taken and is being saved."
fi
任何人都可以幫助我,如果聲明?我可以讀取正在運行的gphoto進程的當前輸出行嗎?
我期待使用'expect'先運行'gphoto -wait-event',然後監視「Downloading」字符串是否存在,當它發生時,將一些系統範圍的變量(例如「 gphotoIsBusy「)設置爲1,當檢測到」Saving「字符串時再次將其關閉。任何人都知道如何讓預期持續監控,像這樣開啓/關閉變量? – ajlowndes