Administration Guide : Adding and configuring input Hot Folders : Using Xinet Hot Folders to do more than print (Custom processing)

Using Xinet Hot Folders to do more than print (Custom processing)
The Hot Folder daemon, hotfd(1M), is generally used to turn a directory into an area where PostScript and PDF files are quickly passed on to print queues. The hotfd(1M) daemon can also be configured to do more than simply passing PostScript and PDF to print queues. An option, (Custom processing), in the Spool to print queue pop-up list exists for this purpose.
When you select it, two type-in boxes appear on the page:
They allow you to either pass on a file or to stream a file through a pipe to Standard Input. Which you choose really depends on how the script or program you call works. Please see the hotfd(1M) manual page for further information.
Example: custom processing using the ex option (reading from a file argument)
When you use its ex flag, the Hot Folder daemon can pass files (PostScript or not) to scripts, that then can perform a variety of actions. The following example shows how to use a Hot Folder to automatically create GIF files from PostScript, PDF or other image files:
1.
2.
Select (Custom processing) from the Spool to print queue pop-up list.
3.
Enter a command in the Enter custom processing command that will read from a file argument type-in box.
Information in this type-in box will automatically reconfigure the hotfd(1M) daemon’s configuration file, /var/adm/appletalk/hotfolderconf on Unix systems and C:\Program Files\Xinet\FullPress\Admin\hotfolderconf on Windows, so that it calls the script whose name you enter here, using the daemon’s ex flag. (In this example, we’ve used a script called GIFscript. Step 4. provides more information about the actual script.)
In other words, when you submit a command using this type-in box, you will automatically update the hotfd(1M) configuration file:
On Unix systems the entry there will look like this:
/space/jamie_tests/HotScript:*:ex=/space/jamie_tests/GIFscript $f$ $F$:dt#15:
On a Windows system the entry will look like this:
C:\space\jamie_tests\HotScript:*:ex=cmd.exe /c cCoLOn\hot-bats\GIFscript.bat $f$ $F$:dt#15:
Note that on Windows, cmd.exe /c has been prepended before the path to your script so that DOS knows to run a batch file. Further, note the syntax for the colon in the path for the script: c: is denoted as cCoLOn. (This capitalization is significant.)
On all platforms, the script has two arguments:
$F$ = the file name only
$f$ = the full path to the file (including the file name)
Inside the script, you can refer to those arguments as $1 and $2 (Unix) or %1 and %2 (Windows), or anything else that refers to command-line arguments. Do not, however, try to evaluate $f or $F—that won’t work.
4.
On Unix:
#!/bin/csh -f
set d=/raid/all_gifs
/usr/etc/appletalk/imagetox -xgif -crgb "$1" > "$d/$2:r".gif
chmod 777 "$d/$2:r".gif
The d variable sets the output directory for the new files. The :r will strip out the suffix (which might be .eps, .dcs, etc.) so that the new suffix .gif can be added.
We’ve enclosed the $1 and $2 within quotes to handle spaces in file names.
Note: If you are working on a OS X system, be sure not to run the csh command with a -fx flag. If you do, the script will not be run when called by hotfd(1M).
On Windows:
set d=f:\testdir\images\all_gifs<br> set e=%2
"c:\program files\xinet\fullpress\imagetox" -xgif -crgb %1 > "%d%\%e%".gif
The d variable sets the output directory, and the e variable provides the name of the output file itself
Until then, the output files will retain their original extensions, e.g., if you convert image.jpg, the output file will be named image.jpg.gif.
5.
6.
Click Submit to restart hotfd(1M).
This will force hotfd(1M) to reread the hotfolderconf file.
Some possible uses for Hot Folders
Drop images of various file types into a Hot Folder, then call imagetox(1) to convert a copy of each one into a GIF.
Drop files into a Hot Folder, then have a script employ ksmv (see kats(1)) to move files to an area which will be archived nightly.
Print to a PDF queue, then make that queue’s destination a Hot Folder that will copy the PDF file to a saved location. (While the same results could be achieved with a Success destination that was also a PDF queue; the PDF would be made twice.)