inotify to watch a directory then print and move
Hi,
I am new to the scripting idea, and I need to create a script to do the following. (A bit of background) I want to use cheese as a photo booth at a major family function. After each photo is taken it is saved by cheese to ~/Pictures/webcam, each picture is named with a timestamp only. The idea is to automate the printing of each photo so that all the guests have to do is pose and shoot, and then the printer will print 2 copies of each, and once printed they can be moved to the ~/Pictures/webcam/printed folder. I am using a HP printer with a Printer name of Photosmart-C5200-Series. What would be a good way to achieve this, please? Andrew Greig Melbourne Australia |
Hi,
what I can't provide you the exact commands, but with incrond/inotify you should be able to monitor directory for changes then create a script to run on an event that inotify generates (let's say new file added: IN_CREATE). - How to Monitor directory for changes The script would be just : Code:
mv "~/Pictures/webcam/filename" "~/Pictures/webcam/printed/" good luck |
You could do it this way:
Code:
inotifywait -m -e close_write ~/Pictures/webcam --format "%w%f" | \ The output of the inotify is piped to a while loop (alternatively xargs could be used to run a command for each filename input). The while loop reads the filename from standard input, prints it to the printer, and then moves it to the destination directory. If you are using CUPS for your printing, then there are some image processing options that can be specified if the default is not what you want. (I noticed your question on the MLUG list, but hadn't had a chance to respond). |
Work to be done now, thanks
I am very grateful for the rapid responses and for the explanation of the instructions. I will not get a chance to work on this, now until Saturday, but I am quite excited about the prospects.
Andrew Greig |
To Neonsigmal - Thanks
Hi Neonsignal,
i cut and pasted your script into a console, and the lack of response indicated i needed to d/l inotify tools, that done, the script worked perfectly the first time. It's a beautiful thing, thank you for your efforts on this, I am so relieved that I will now be ready for the party. Yours faithfully Andrew Greig Melbourne Australia |
All times are GMT -5. The time now is 05:29 AM. |