Latest CGI version for Mac OS X

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Latest CGI version for Mac OS X

Post by Nonsanity » Tue Jun 03, 2008 8:35 pm

Does anyone know what the most current version of the CGI engine for Mac OS X is? The only reference I can find is to version 2.1.2 located here:

ftp://ftp.runrev.com/pub/revolution/dow ... /Darwin.gz

I don't need an Intel version myself, though I know others that do.
~ Nonsanity
~ Chris Innanen

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Wed Jun 04, 2008 12:21 am

Going on the assumption that 2.1.2 is the latest, I tried to use it for my purposes. I got the permissions set correctly on the app, stack, and cgi files. And using my stack as a library from the cgi text script, I found out that I needed to save the stack in legacy mode.

But then I found out that I can use the "do mystuff as applescript" on a Mac as a CGI. And that totally throws out the possibility of controlling Mac apps through a Revolution CGI!

Anyone have any good news for me here?
~ Nonsanity
~ Chris Innanen

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Wed Jun 04, 2008 7:57 am

While I understand your disappointment, I think it's logical that the Darwin version has no support for AppleScript - Darwin is the open-source basic Unix underpinning for MacOSX, and AppleScript is in one of the closed-source layers above it, that make the Mac a unique environment. It is perfectly possible to run Darwin on a computer without having Aqua or any of the other fancy bits - and so there's no API to tap into.

Not all is lost, however: you can use the shell function and the osascript command-line executable, which takes either a file or a statement as parameter and executes it for you.
For more information on osascript see the manpage here: http://developer.apple.com/documentatio ... ipt.1.html

Another option is to use a system like RevOnRockets http://www.revonrockets.com, where you basically have an HTTP server running as a graphical Revolution application, which gives you access to all the features that Revolution 2.9 has to offer.

And there's nothing to stop you from using Apache + RevCGI + RevgOnRockets, by creating cgi scripts that talk to the RevOnRockets server - that way you can leave security configuration and SSL communication to be handled by Apache.

For more information on using libURL from a Rev cgi script, go to: http://www.lacscentre.com/liburl/releases.html

Hope this helped,

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Wed Jun 04, 2008 6:04 pm

Ah... osascript shell command is just what I need to fill the gap.

That the Darwin version of Revolution doesn't have this functionality built in is understandable, but the existence of things such as RevOnRockets should highlight a need for more up-to-date CGI versions of the Revolution engine - Including one native for Mac OS X specifically.

Thanks for the shell reminder!
~ Nonsanity
~ Chris Innanen

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Wed Jun 04, 2008 9:37 pm

...Problem is, from the 2.1.2 Darwin RevCGI engine, if I do:

get shell( "osascript test.scpt" )

Then the process gets stuck in there and never comes out. It works fine if I put the same string into a terminal window. If I do:

get shell( "man osascript" )

I'm told that such a command doesn't exist, though doing the same "man osascript" in a terminal window gives me its help page. Other basic commands through the shell() function, like "ls", work fine.

So something isn't right with the osascript command in the CGI shell. Has anyone ever used this before and gotten it to work?
~ Nonsanity
~ Chris Innanen

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Wed Jun 04, 2008 9:48 pm

Actually... It looks like the osascript command will work, but any applescript it runs won't be able to access WindowServer, so it won't be able to control any running applications. Sorta makes the whole thing pointless, that.
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL. osascript: coudn't save changes to script /Library/WebServer/CGI-Executables/test.scpt: Permission denied
I'll continue to test, but it doesn't look good so far...
~ Nonsanity
~ Chris Innanen

Nonsanity
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 86
Joined: Thu May 17, 2007 9:15 pm
Location: Maryland, USA
Contact:

Post by Nonsanity » Wed Jun 04, 2008 11:44 pm

Okay... It's a hack, but I've got it.

Open: /private/etc/apache2/httpd.config (as root)

And change the "www" in the following two lines to the user name that is going to be logged in (for sure!) when running the CGI scripts:

User www
Group www

Then go to System Preferences, Sharing, and turn Web Sharing off then on again. This will restart it under the new user instead of the "www" user.

Now Apache, the web server, will have access to the WindowServer process of the logged in user and osascript commands will be able to manipulate running processes.


The downside to this is that the web server is no longer running under its own user account. What side effects this will have on security or interactions with other tasks is unknown to me. Use at your own risk.
~ Nonsanity
~ Chris Innanen

Post Reply

Return to “CGIs and the Server”