User:GreenC/awb/cygwin

To run Unix scripts (bash, tcsh, zsh, etc) with native Windows AWB.

Method 1: Cygwin
This method is straightforward. It has the disadvantage of being slower. A complex unix script which calls many external programs may be 100x slower than running under a native unix. Fine for simple tasks.


 * 1) Download and install Cygwin.
 * 2) In AWB Tools->External Program Processing


 * * Enabled (check)
 * * Program or script: c:\cygwin\bin\bash.exe
 * * Arguments or Parameters: /home/username/script/script.bsh "%%title%%"
 * * Input/Output file: c:\cygwin\home\username\script\article.txt

Couple notes:


 * 1) The forward and backward slashes above are not a typo!
 * 2) The script takes the title of the article as the first argument.
 * 3) The script looks for article.txt in "I/O file" location, make changes to it, then saves it where AWB picks it up.

Example usage: User:Green Cardamom/kirjasto.sci.fi/source a completed project with full source.

Method 2: Virtualbox
This method runs unix scripts natively. It does not require wine which has problems with external scripts (update: see patch ). AWB runs on Windows as normal, the unix script runs under unix as normal. The best of all worlds.

Briefly: install Virtualbox, install a Unix guest OS (eg. Linux Mint), create a common shared folder between the Windows host OS and Unix guest OS. Then create two demon scripts (versions below), one on the Windows and the other on Unix, that monitor the shared directory. The scripts run in a loop looking for the existence of a file and act when it appears. Conceptually it looks like this:


 * AWB <-> demon-win <-> [shared directory] <-> demon-linux <-> unix script

Process flow: AWB sends the name of the article to demon-win (running in windows) which drops it into the file "name.txt" in the shared directory. demon-linux (running in unix) monitors the directory for name.txt and retrieves it, then spawns the unix script. The unix script downloads the article, processes it and drops the updated article into the shared directory as "article.txt". Demon-win sees article.txt and exits, thus passing control back to AWB. AWB then picks up article.txt and continues on as normal.

Setup:

The demon-win script is added to AWB's "External Program Processing" like this:


 * 1) In AWB Tools->External Program Processing


 * * Enabled (check)
 * * Program or script: c:\cygwin\bin\gawk.exe
 * * Arguments or Parameters: /home/username/script/demon-win.awk "%%title%%"
 * * Input/Output file: c:\shared_directory\article.txt

Customize the drives/paths as needed but retain the correct forward and back slashes. This example assumes cygwin's version of GNU Awk.

The demon's source code is here (GNU Awk 4.1):


 * demon-win.awk (requires cygwin)
 * demon-lin.awk

Customize paths as needed.