Getting another web page

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Getting another web page

Post by andyh1234 » Wed Sep 26, 2007 1:06 am

Just a quickie!!

Im trying to load another webpage with a cgi script, but struggling.

I want to load a page on another server, check it against a copy I have, and if its changed make a log, send an email etc.

I can do it no problem using the put url "xxx" into xxx within the Studio, but this doesnt seem to work in the cgi on the linux server, I assume before the cgi is not v2.8.x

I can do all the rest, sending the email etc.

Any ideas on how to grab another web page and put it into a buffer using the cgi???

Thanks

Andy

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

Post by Mark » Wed Sep 26, 2007 1:22 am

Hi Adny

I think this should work. Can you post your script?

Best,

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

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Post by andyh1234 » Wed Sep 26, 2007 3:53 pm

Sure,

A very simple script is...

---- INSIDE REVOLUTION....
on mouseup
put "Content-Type: text/plain" & cr & cr
put "Loading..."
put "http://www.google.com/" into myURL
put URL myURL into myReturn
put myReturn
end mouseup

---- ON THE SERVER
#!/usr/local/revolutioncurrent
on startup
put "Content-Type: text/plain" & cr & cr
put "Loading..."
put "http://www.google.com/" into myURL
put URL myURL into myReturn
put myReturn
end startup


Works fine inside studio, but not on the server. Studio returns all the text and the html for the page, the server just returns 'Loading...'

The path #!/usr/local/revolutioncurrent is correct on my server btw!

Thanks

Andy

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

Post by Mark » Wed Sep 26, 2007 4:52 pm

Andy,

I have tried it and at the moment I can do no more than confirm that this does't work.

I am able to open sockets to another machines from a remote web server. Depending on what you want to do exactly, that might be an alternative for you.

Best,

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

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Post by andyh1234 » Wed Sep 26, 2007 5:47 pm

Thanks Mark,

I figure its probably a timeout, ill try and work it out using more code or just code it in perl, just hoping it was a quick fix in revolution!

Thanks

Andy

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

Post by Mark » Wed Sep 26, 2007 7:12 pm

Andy,

I set the timeout to 20 seconds and still nothing happened. In fact, What surprises me is that I don't get an execution error, while the result is also empty after putting the url. There is not timeout error either.

Best,

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

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Location: London, UK
Contact:

Post by Mark Smith » Sat Sep 29, 2007 10:27 pm

I think you'd have to have libUrl available for it to work.

It's possibe to separate libUrl out from the IDE, but remember that the cgi engines are still in 'legacy', so you'd hav to put libUrl into a stack and save it in legacy format.

Then you could load it as a library in your cgi:

start using stack "libUrl.rev" (assuming you saved in the same directory as the cgi). This should work, I think.

Best,

Mark

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

Post by Mark » Sat Sep 29, 2007 10:36 pm

Mark,

I thought of that, but there is no execution error. I wonder why?

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

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Location: London, UK
Contact:

Post by Mark Smith » Tue Oct 02, 2007 2:09 am

I've tested this now and I'm afraid it doesn't seem to work - my guess is that libUrl is tied in to the engine (I think calls like 'get url "someUrl" go to the engine which then calls libURL, and it seems like this doesn't work with the cgi engines).

The other option is to use curl - this seems to work fine.
On OS X (which has curl installed by default), the call would be:

get shell("curl -s " & "http://www.somesite")

I'm afraid I don't know if this will be helpful on Windows.

Best,

Mark

andyh1234
Posts: 442
Joined: Mon Aug 13, 2007 4:44 pm
Location: Eccles UK
Contact:

Post by andyh1234 » Wed Oct 03, 2007 11:56 am

My server is on Linux, so I can install Curl, thanks Mark.

Post Reply

Return to “CGIs and the Server”