我正在 Perl 中创建一个脚本,该脚本将从相机中拍摄照片并检查是否拍摄了任何新照片。在 Ubuntu 中,我使用 gphoto2 在相机中搜索图片,然后下载任何新图片。我在网上看到了几个接近满足我需求的脚本,但我遇到了在每次 gphoto2 请求后都需要重置 USB 端口的问题。我现在唯一遇到的问题是,如何将下面的输出保存到我可以比较的数组或文件中?
There is no file in folder '/store_00010001/DCIM/112EOS5D'.
There is no file in folder '/store_00010001/DCIM/113EOS5D'.
There are 3 files in folder '/store_00010001/DCIM/114EOS5D'.
#1 IMG_0001.JPG rd 347 KB image/jpeg
#2 IMG_0002.JPG rd 342 KB image/jpeg
#3 IMG_0003.JPG rd 336 KB image/jpeg
There is no file in folder '/store_00010001/MISC'.
对此
There is no file in folder '/store_00010001/DCIM/112EOS5D'.
There is no file in folder '/store_00010001/DCIM/113EOS5D'.
There are 5 files in folder '/store_00010001/DCIM/114EOS5D'.
#1 IMG_0001.JPG rd 347 KB image/jpeg
#2 IMG_0002.JPG rd 342 KB image/jpeg
#3 IMG_0003.JPG rd 336 KB image/jpeg
#4 IMG_0004.JPG rd 348 KB image/jpeg
#5 IMG_0005.JPG rd 342 KB image/jpeg
There is no file in folder '/store_00010001/MISC'.
这是产生代码的原因。gphoto2 --list-files 给出输出,./reset 是一个简单的 c 代码,用于重置 USB 端口,因此 gphoto2 可以做到这一点。
sub main {
while (1) {
system("gphoto2 --list-files");
system("./reset /dev/bus/usb/003/021");
sleep 5;
}
}