Premise Best place to put a script that you want to only run on SYS start up?

Motorola Premise

etc6849

Senior Member
I have a script I want to run when the SYS service is started. Is there a place within Builder to add it?
 
Can you not put it in Default->Globalscripts? Or maybe in timers? There is a command that SYS can use for kicking off a program/process - that combo may do the trick?
 
I already have the global script made. However, I'm not sure what event (e.g. property change) occurs on start-up that would execute the global script.
 
Check out server monitor class in the help. A lot of helpful features. Haven't experimented (played) with it, but at first look, may be the place you are looking for.
I don't know. Maybe its the place we're all looking for?
cool.gif
 
I see the class you're talking about. It would work if the code was exposed for us to modify, but it's not. The problem is if you create an extension to a "non-module" (add-ins or subsystem classes), you can't add a property change script. I tried this to be sure :(

Since we know a port is "initialized" on start-up, I'll have to build a custom module that exploits this (I wasn't wanting to do it this way, since it is ugly to put custom code under a module). It also means sacrificing a serial port just for the sake of checking for a reboot. The other alternative is to build a windows service that also acts as a SYS add-in.

EDIT: Attached is a temporary solution. Import the Module, create a new CustomDevice of type RestartMonitor and set the network property to that of a spare COM port. When I run out of COM ports, I'll attempt to build a windows service (something that I've never done before so it may/may not ever happen). Examine the module's code and add whatever you want to execute on a reboot to the end of sys://Schema/Modules/Restart/Classes/RestartMonitor/OnChangeRestart
 

Attachments

  • RestartMonitor.zip
    1.7 KB · Views: 0
If you right click on server, you can add a property change script..I enabled expert mode and was able to add some text to the property change script. Basically, I used server monitor state checked in as the prop change...
 
Hi Chuck,

I'm not sure what I'm doing wrong, but when I click on "Server" (two ways to get there in Builder: 1. on the left click the Define view, then click server 2. Browse the Premise SYS tree and find Server), I don't get an option for adding an onchangescript. However, if I browse to the ServerConfig class that "Server" inherits from, you can add a property change script. The catch is any change you make will be nuked following a reboot; also, after you initialize the property change script and click on it to enter code, SYS quickly closes the script editing window.

However, you're suggestion is an interesting approach. I believe if you perform something similar to what 123 does in this thread: http://www.cocoontech.com/forums/index.php?showtopic=13367 you could make a permanent change to the SYS Schema. I'm going to try this on a test PC (of course) :)

PS: In the mean time, it sounds like there's an easier way to do this and you've done it, so please keep helping me :)
 
I did some digging around and found a module that is executing a procedure at start. Check out the Taskpads module. Under the Global node you'll see this:

Code:
' Initialization Functions
' Creates the Browser Interface for TaskPads


on error resume next ' prevents constant redefinition errors

const TP_SCRIPT_FOR_MENU = "if not sysevent.clientSession.CurrentLocation is nothing then sysevent.ClientSession.CurrentLocation.REPLACETHIS"

on error goto 0

TPCreateInterface

'Main body of work
sub TPCreateInterface()
''''''Shortened
''''''
end sub

Everytime the system starts it executes TPCreateInterface. So the trick appears to be to create a global but to not wrap the code in a function or sub.


Haven't tried it myself, but it looks like it does what you want.
 
Thanks John, it works! Chuck's first reply makes a lot of sense about using a globalscript... Doh! Boy do I feel dumb :wacko:
 
If you had only read the help under the help topic "Adding a Global Script". LOL. Of course, I only thought to look there after I read the solution.

The VBScript placed in Global Scripts are executed every time that Premise Server starts. Take advantage of this by placing script outside of Functions or Subs. To avoid this execution, place code within a Function or Sub and it will only execute when the procedure is called from another script.
 
FWIW, here's what how I handle scripts that need to execute upon Premise's startup. I've created a Module, and Globalscript, called "AutoExec". The Globalscript defines subs and functions and then calls whatever it needs to run. In this example, the function gSetPremisePriority could be defined as a 'sub' but I've chosen to use 'function' to demonstrate how subs and functions are invoked.
 

Attachments

  • AutoExec.png
    AutoExec.png
    56.5 KB · Views: 12
Back
Top