我使用 --wait-event-and-download 参数运行 gphoto,这样我使用红外遥控器拍摄的照片就会保存到计算机中。
我设置了第二个脚本来中断等待过程并以编程方式拍照,如下所示:
#!/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
任何人都可以帮我解决这个 if 语句吗?我可以读取正在运行的 gphoto 进程的当前输出行吗?