Page 1 of 1

RunRev / LiveCode SERVER!

Posted: Thu Feb 21, 2013 11:34 pm
by revRider
Attempting to create a web page that poles ichat for a users status..

Am I just assuming this should work?

Dawns on me running scripts might not work on "server". it works as a script and as a application. Currently I have it ran as a timed script, but that seems wasteful of system resources. So trying something different, and to better learn what LiveCode can do.

Thanks
~David

Code: Select all

<?rev

	put quote & "Finder" & quote into myFinder
	put quote & "iChat" & quote into myMessages
	put quote & "pipedream01@chat.server.org" & quote into myFriend1
	put quote & "pipedream04@chat.server.org" & quote into myFriend2
	put quote & "Library:WebServer:Documents:sites:Pipedream:" & quote into myPath
	put quote & "iChat.html" & quote into myFile
	put quote & "Library:WebServer:Documents:sites:Pipedream:iChat.html" & quote into myFullPath
	
	put "tell application "& myFinder & cr & \
	"set startupDisk to startup disk as string " & cr & \
	"end tell" & cr & \	
	"tell application "& myMessages & cr & \
	"set iStatus to get status" & cr & \
	"set message to get status message "& cr & \
	"set isAvailable to (status of buddy " & myFriend1 & ")" & cr & \
	"set isMessage to (status message of buddy " & MyFriend1 & ")" & cr & \
	"set isImportant to isMessage " & cr & \
	"end tell " & cr & \
	"set html to isImportant " & cr & \
	"if length of html < 8 then " & cr & \
	"tell application "& myMessages & cr & \ 
	"	set iStatus to get status " & cr& \
	"	set message to get status message "& cr & \
	"	set isAvailable to (status of buddy "& myFriend2 &")" & cr & \
	"	set isMessage to (status message of buddy "& myFriend2 & ")" & cr & \
	"	set isImportant to isMessage "& cr & \
	"end tell " & cr & \
	"end if "& cr & \
	"if length of html > 8 then " & cr & \
	"set parentFolder to startupDisk " & myPath & cr & \ 
	"set fileName to parentFolder " & myFile & ")" & cr & \
	"try " & cr & \
	"if exists file FullFilePath then " & cr & \
	"	set the file_to_delete to startupDisk " & myFullPath & cr & \ 
	"	delete the file_to_delete " & cr & \
	"end if " & cr & \
	"if not (the file fileName exists) then " & cr & \
	"	set theFile to open for access fileName with write permission " & cr & \
	"	close access theFile "& cr & \
	"end if " & cr & \
	"on error" & cr & \
	"	try " & cr & \
	"		close access thePath " & cr & \
	"	end try " & cr & \
	"end try " & cr & \
	"set theFile to open for access fileName with write permission "& cr & \
	"set eof of theFile to 0 " & cr & \
	"write html to theFile " & cr & \
	"close access theFile " & cr & \
	"return html " & cr & \
	"end if" into tScript 
      put " Updating URL …"       
     Put tScript
     do tScript as applescript 
?>

Re: RunRev / LiveCode SERVER!

Posted: Thu Feb 21, 2013 11:41 pm
by Klaus
Hi David,

this not works! :D

"Livecode Server" is a "server side scripting" engine like PHP etc. and has of course NOT access to the users harddisk or system!
And we are all very happy about this and so should you! 8)


Best

Klaus

Re: RunRev / LiveCode SERVER!

Posted: Thu Feb 21, 2013 11:48 pm
by revRider
The "Server" has an ichat client running, and 'sees' the statues of other "servers" (that also run ichat)..

We want the script to run ON the server, just like PHP, or a web page..

And you are correct I wouldn't want anyone pushing scripts to my server and running..

There is already a applescript on the server that executes every 15 minutes.. But sometimes the timing get messed up, and we are left with no status. The idea is to have the script run/triggered when someone hits the page...

~David

Re: RunRev / LiveCode SERVER!

Posted: Fri Feb 22, 2013 2:40 am
by sturgis
If you already have an applescript that works, perhaps you can copy it to a location where lc server can get to it, and use shell() to execute it. Not sure it will work, but worth a shot I guess.

Re: RunRev / LiveCode SERVER!

Posted: Fri Feb 22, 2013 10:51 am
by Klaus
Ah, I understand.

But I doubt that this will be allowed for security reasons!

Re: RunRev / LiveCode SERVER!

Posted: Thu Feb 28, 2013 12:52 am
by revRider
So, anyone have any ideas on how to 'trigger' a script, or script bundle (app) from LiveCode server?

~David