RunRev / LiveCode SERVER!

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
revRider
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 49
Joined: Sat Apr 02, 2011 4:06 pm

RunRev / LiveCode SERVER!

Post by revRider » Thu Feb 21, 2013 11:34 pm

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 
?>

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: RunRev / LiveCode SERVER!

Post by Klaus » Thu Feb 21, 2013 11:41 pm

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

revRider
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 49
Joined: Sat Apr 02, 2011 4:06 pm

Re: RunRev / LiveCode SERVER!

Post by revRider » Thu Feb 21, 2013 11:48 pm

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

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: RunRev / LiveCode SERVER!

Post by sturgis » Fri Feb 22, 2013 2:40 am

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.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: RunRev / LiveCode SERVER!

Post by Klaus » Fri Feb 22, 2013 10:51 am

Ah, I understand.

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

revRider
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 49
Joined: Sat Apr 02, 2011 4:06 pm

Re: RunRev / LiveCode SERVER!

Post by revRider » Thu Feb 28, 2013 12:52 am

So, anyone have any ideas on how to 'trigger' a script, or script bundle (app) from LiveCode server?

~David

Post Reply