I have been working on some external integrations with witango.

Most of the time I look for a COM object when I need to do an integration interface with witango. But more and more com objects don't work within witango. And COM objects only work with Windows witango.

But almost all apps have some type of command line interface to use. The problem is the limitations in the witango external action that have limited me.

So I wrote this little command line tool that acts as a wrapper for the witango external action. You pass the cmd you want to run as a env var named CMD and the wrapper runs it, with any switches you want. It also will accept a timeout parameter, so it will destroy the shell after a period of seconds, in case hung. It returns easily parsed results. All info is in the attached readme, which is also in the zip.

So far I have used this little utility in a couple of ways.

1. ImageMagick interface. I use it for on the fly processing of images when needed. A taf is included in the download that demonstrates how to upload and instantly create a thumbnail.

2. Subversion. I love subversion. I have several main code repositories at my office for witango apps/sites. I have a couple of developers that can checkout the code remotely, and checkin, and it keeps all revisions and notes. I made a working copy of the repo on my production servers. And a working copy on my test server.

When anyone checks in code, I wrote a post commit hook to automatically update the checked in code to the test server. So we can instantly test our new witango code. So if any developer checks in there code, and they can be in london, or LA, or wherever, our common test server is instantly updated.

Then using the witango_cmd wrapper. I made a taf that is my administration console for my production servers. I can from the console, check the subversion log to look at the changes that have been made by myself or other developers. I can then review the updated files, and make sure there is no code that has not been tested. If I approve, I click a link in the console, and my wrapper runs the svn update for that repo, and the production code is instantly updated to the version on the test server. Of course my console is password protected. So only I can update working code to production servers.

This has solved so many problems, I cannot tell you.

3. I use TitanFTP as our ftp server. It allows me to ONLY use secure connections, and and add virtual ftp servers so I can make a ftp server for a client, and give him only a certain amount of space that I want. Even throttle BW if needed.

TitanFTP has a com object to administrate, doesn't work in witango, believe me I tried. But they also have a command line utility, srxCFG.exe. So I made a witango administration console that I set to only administer the ftp server of the client, and the client can add/edit/delete there own users.

All this was done with the witango_cmd utility I wrote. So I thought I would share it. You can get it at:

http://www.bighead.net/tools/

If you use it in production, send me paypal ([EMAIL PROTECTED]) of like $25, and I will send you a non expiring version, and examples for subversion and titanFTP. My five kids will thank you.

I am sure there are many other uses, send me the tafs, and I will make them available if you make one.

Here is a screen shot of my production server administration console:

http://www.bighead.net/tools/adminconsole.jpg

Here is read me for witango_cmd:


Witango CMD (CL) Wrapper


Install
For imagemagick example, you must install imagemagick on your witango server for this to work, and the imagemagick utilities should be in your PATH environment variables to run from any directory. This is done for you in the imagemagick installations. You may have to restart after installation. To test valid imagemagick installation, run "convert" from the command line in your user directory, and you should see a help screen for the convert command. Windows executable installer and linux installer can be found here:

http://www.imagemagick.org/

If you are looking for a simple installation for Mac, without having to compile the binaries, go here:

http://www.entropy.ch/software/macosx/

This individual has created a simple package installer, and I have verified it works.

Place the witango_cmd folder wherever you want to access from witango. NOTE: The windows and linux executables are self contained, however the mac executable requires the lib folder and .rsrc file, keep them together.

Witango Usage
Included in the Witango_imagemagick folder are 3 excutables. One for each platform supported.

witango_cmd.exe for windows
witango_cmdX for Mac OS X
witango_cmd for linux

There is also a taf file to show how to create an upload form, accept the image, create thumbnail, and present thumbnail. The witango_cmd app requires only one argument. This argument is "CMD", and is passed as an environment variable. This argument is run in a shell.

There are 2 other arguments that may be input:
RTNCMD
Acceptable values are 1 or 0. If 1, then the witango_cmd app will return the first line of resuts as: CMD --> the value of the CMD you passed in. This is for debugging purposes.
TIMEOUT
Witango_cmd will stop the executed command after this value in SECONDS. Default is 300. Do not set this higher than the witango querytimeout value. I have found that if you call a shell from witango, and it times out, the shell will keep running, and if it is hung, stay hung. So the witango_cmd timeout is designed to halt the shell process after the timeout.

Parsing Results
The results are output in the @@results var as an array of 1 column many rows. First row is always the CMD --> line if you requested. Otherwise first line is always the exit code of the cmd you passed in this format. ";ResultCode --> 0" or whatever the result is.
Second line is the text result of the cmd you sent, which would have been what you would see in the console if you ran at the command prompt. ";ResultText --> msgtext"
Last line is a copyright line.

The ResultText may contain several lines of text. You cmd may have outputed several lines, and they will all be included. This is why witango_cmd message lines all start with ";" to make it easier to parse. I used "-->" as a delimiter so that hopefully, and message you get, won't have that, and so it is easier to parse.

IMPORTANT: When parsing for error, you should only have to check the first line "ResultCode". If it is 0, no error, anything else is an error. For instance, image magick may output a message that looks like an error, but ResultCode = 0, and the process completed successfully. IM was just giving you info. Every command line utility is supposed to follow this method, returning 0 on success, and some other int on fail.


Notes
I have tested on mac and windows, but have not tested at all on linux, so any feedback would be appreciated. It should work on RedHat and SuSE distributions.

I explored creating a dll for these functions, but this seemed the best, since it doesn't run in the witango memory space, and I don't want to be crashing anyones servers.

This BETA application expires on 6/1/2005 at 12:00am. If you want one that doesn't expire, and a custom tagline at the end of results, send paypal $25 to [EMAIL PROTECTED] My 5 kids will thank you.

Please send any feedback to [EMAIL PROTECTED]

� 1999 - 2005 BigHead Technology

--

Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
[EMAIL PROTECTED] - [EMAIL PROTECTED]
http://bighead.net/ - http://eventpix.com/

Reply via email to