Converting scripts to (Linux) text CGI files

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Clarkey
Posts: 109
Joined: Fri Jun 11, 2010 11:10 am
Location: UK

Converting scripts to (Linux) text CGI files

Post by Clarkey » Wed Jul 14, 2010 7:32 pm

Hi folks, I'm experimenting with adding a simple CGI service to my Ubuntu web server and I'm struggling to get a basic test CGI script working. From the various threads in this section I think the problem is to do with converting Mac-based script text files to UNIX-compatible text files for the server to consume (carriage returns vs. line feeds, etc).

Is there an easy way to process an OSX-created script file to produce a UNIX-formatted text file? I guess this would be a standard function when creating a stand-alone for a UNIX client but I'm just fiddling with the occasional script at this stage.
Best,
Keith..

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Converting scripts to (Linux) text CGI files

Post by Mark » Thu Jul 15, 2010 7:43 am

Keith,

What are you using to write your CGI scripts? If you write them in a text field in RunRev, you can write a simple script to save the text of the field to disk. The resulting file should be compatible with your Ubuntu server.

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Clarkey
Posts: 109
Joined: Fri Jun 11, 2010 11:10 am
Location: UK

Re: Converting scripts to (Linux) text CGI files

Post by Clarkey » Thu Jul 15, 2010 8:59 am

Mark,
Thanks for the tip. Just to clarify, this would suggest that Revolution text fields use UNIX-style format (line feeds rather than carriage returns)? Does Revolution work this way throughout - should I be able to copy and past from the script editor direct into TextWrangler, (my usual tool for editing web server text files) and be confident that the resultant text file will be UNIX-compatible?
Best,
Keith..

Clarkey
Posts: 109
Joined: Fri Jun 11, 2010 11:10 am
Location: UK

Re: Converting scripts to (Linux) text CGI files

Post by Clarkey » Thu Jul 15, 2010 11:01 am

Upon further experimentation, I'm not sure whether my problem is about file format or something else. I have edited the three test CGI script files directly on the server using Transmit and all fail with the same error code. For example, the following code copied direct from the 'Hello World" CGI example on http://www.hyperactivesw.com/cgitutorial/scripts1.html...

Code: Select all

#!revolution -ui

on startup
  put "Content-Type: text/plain" & cr & cr
  put "Hello World!"
end startup
...returns a 500 error with the messages: The server encountered an internal error and was unable to complete your request.
Error message: Premature end of script headers: hello.cgi

Any clues whether this is a CGI file format error or something else - such as some Ubuntu or Apache config needed to register the revolution CGI engine? Incidentally, the 'revolution' engine is in the cgi-bin folder, alongside the test scripts and is a renamed copy of Runtime/Linux/x86-32/Standalone from my Enterprise 4.5.0-dp-3 RunRev instance. (The server is definitely set to support CGIs as a test CGI in the same folder works OK.)

Any ideas gratefully received.
Best,
Keith..

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Converting scripts to (Linux) text CGI files

Post by bangkok » Thu Jul 15, 2010 11:16 am

Clarkey wrote: Any clues whether this is a CGI file format error or something else - such as some Ubuntu or Apache config needed to register the revolution CGI engine? Incidentally, the 'revolution' engine is in the cgi-bin folder, alongside the test scripts and is a renamed copy of Runtime/Linux/x86-32/Standalone from my Enterprise 4.5.0-dp-3 RunRev instance. (The server is definitely set to support CGIs as a test CGI in the same folder works OK.)
I guess you have chmod 755 the revolution binary and your CGI file ?

I never used RunRev CGI on Linux with Apache. Only on Windows.

From my point of view, the path to the revolution binary was the most tricky part. You should perhaps check it.

http://forums.runrev.com/phpBB2/viewtop ... =15&t=5483

Other idea : make a ldd on the binary.

Right now, I'm struggling on Ubuntu, with Apache but with the new product RunServer. I have also issues with error 500, and it seems (first tip given by the RunServer support) that a library is missing.

Clarkey
Posts: 109
Joined: Fri Jun 11, 2010 11:10 am
Location: UK

Re: Converting scripts to (Linux) text CGI files

Post by Clarkey » Thu Jul 15, 2010 1:30 pm

Thanks for the response bangkok,
Yes, I've 755 permissions set on revolution and the CGI files. I think I need to check that the necessary libraries for RunRev are in place, as per this tip http://www.sonsothunder.com/devres/revo ... cgi001.htm

This may prove difficult as my Ubuntu server is a VPS supporting multiple sites and I'm testing Rev in a subdomain - which means multiple configuration and CGI folders and fiddling about on the command-line through SSH. Not to mention that my UNIX configuration mgt skills are as limited as my Rev development skills :lol:

For my current feasibility testing purposes, it may prove easier to just rent On-Rev for a couple of months.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Converting scripts to (Linux) text CGI files

Post by bangkok » Thu Jul 15, 2010 1:46 pm

Clarkey wrote: For my current feasibility testing purposes, it may prove easier to just rent On-Rev for a couple of months.
Or try Ubuntu + Apache + Rev CGI on a local machine, before to install it on your remote server.

Starting from scratch, with a basic environnement, could help you to understand all the traps.

As for RunServer (the "local" version of OnRev), I continue my tests. I will post something here as soon as I find a solution that works.

Thanks for the link about ldd. It confirms what RunRev support told me.

Clarkey
Posts: 109
Joined: Fri Jun 11, 2010 11:10 am
Location: UK

Re: Converting scripts to (Linux) text CGI files

Post by Clarkey » Thu Jul 15, 2010 2:41 pm

Running up a local machine with a simplified configuration would be a wonderful idea - if one just happened to be lying around! :wink:

However, as I've never built a server from scratch, I'm fairly certain that even configuring a preconfigured virtual Ubuntu box on my Mac's Parallels partition would mean learning curves for every layer of the stack before I got it working correctly. And, even if I succeeded, I fear it would be something of a lengthy distraction from my app development's critical path.

I was only looking to load up some Rev server CGIs to test some web service integration concepts for my app. Once proven, I'd likely deploy the app using Rev Server - or On Rev, so I don't have to worry about the infrastructure or stack config. As it is, I've already spent more time on the 'plumbing' than the cost of a month's OnRev subscription, so I think I'll buy rather than build, to avoid having to solve the technical issues that don't add value to my app.

Still I'd be interested in knowing what is involved in taming Rev Server, as I'm still considering this option - so good luck with your challenge!
Best,
Keith..

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9852
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Converting scripts to (Linux) text CGI files

Post by FourthWorld » Thu Jul 15, 2010 3:56 pm

Keith - email me as I may have something to help you: ambassador@fourthworld.com
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: Converting scripts to (Linux) text CGI files

Post by bangkok » Thu Jul 15, 2010 4:35 pm

FourthWorld wrote:Keith - email me as I may have something to help you: ambassador@fourthworld.com
Could you share ? :)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9852
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Converting scripts to (Linux) text CGI files

Post by FourthWorld » Thu Jul 15, 2010 5:06 pm

bangkok wrote:
FourthWorld wrote:Keith - email me as I may have something to help you: ambassador@fourthworld.com
Could you share ? :)
Sure, but not publicly yet, not yet quite ready for prime time. But if you have an interest in CGI stuff and have been having trouble with 500 errors feel free to write as well.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Clarkey
Posts: 109
Joined: Fri Jun 11, 2010 11:10 am
Location: UK

Re: Converting scripts to (Linux) text CGI files

Post by Clarkey » Thu Jul 15, 2010 7:26 pm

FourthWorld wrote:Keith - email me as I may have something to help you: ambassador@fourthworld.com
Thanks Richard - you have mail.
Best,
Keith..

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9852
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Converting scripts to (Linux) text CGI files

Post by FourthWorld » Fri Jul 16, 2010 5:44 pm

Got it - thanks. I'm taking most of today off, but when I get back on Monday I'll see if I can put together something useful for you.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Clarkey
Posts: 109
Joined: Fri Jun 11, 2010 11:10 am
Location: UK

Re: Converting scripts to (Linux) text CGI files

Post by Clarkey » Fri Jul 16, 2010 7:42 pm

FourthWorld wrote:Got it - thanks. I'm taking most of today off, but when I get back on Monday I'll see if I can put together something useful for you.
Cool! Much obliged!

Post Reply

Return to “CGIs and the Server”