#1 2015-04-30 07:44:32

ralex
Member
Registered: 2015-04-20

Scripting.cf file

Hi,
I some question about the scripting file :
The default one is  :


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <scripting>
      <enable>true</enable>
      <restrict>
         <location>bin</location>
      </restrict>
      <startup>
         <login>fileserver/bin/onlogin.d</login>
         <rs>fileserver/bin/onstartup.d</rs>
      </startup>
   </scripting>
</configuration>

As far as I understand this means that any groovy script, put inside onlogin.d folder ,will be run on log in, while those put inside onstartup.d will be run on startup.
If so,my first question  is :
How can I add a row to this file to say : "run this script , for example myscript.groovy, that is inside the maintanance folder at 12 a.m?
I guess is something like <tag>fileserver/bin/maintenance </tag> , but I don't know which tag I can use...and I also suppose that this script should not stay inside
<startup></startup> tags , but outside it.

second question :
In the configuration guide there is an example which talks about two scripts : onlogin.rs and onstartup.rs and the scripting.cf file is the following :

<scripting>
<enable> true </enable>
<restrict>
<location> bin </location>
</restrict>
<startup>
<login> fileserver/bin/onlogin.rs</login>
<rs>fileserver/bin/onstartup.rs</rs>
</startup >
< / scripting >

What I'm noticing is that inside login and rs tags are specified these two scripts instead of the folders, as in my scripting.cfg file.
So I'm wondering :
Is sufficient to put the script file inside the "login" tag to get reportserver understand that this script has to be run on log in and that its position , in the file system, is fileserver/bin/onlogin.d ? Similar question for the other script (onstartup.rs).




Thanks in advance ,

Alex

Offline

#2 2015-04-30 20:38:14

Arno Mittelbach
datenwerke
Registered: 2012-02-14

Re: Scripting.cf file

Hi Alex,

startup and login take either a script or a folder. In the latter case all scripts in the folder are run on startup (resp. login). To schedule a script you can use the scheduleScript terminal command.
To run a script every day at 12 use

scheduleScript execute myScript.rs " " every day at 12:00

More information on scheduleScript and onstartup/onlogin can be found in the admin and script guides.

Cheers
-Arno

Offline

#3 2015-05-04 14:57:11

ralex
Member
Registered: 2015-04-20

Re: Scripting.cf file

Hi Arno,
thanks for your support. I tried your code ans it's working on command line.
I also created a script, called schedule.updated.db.rs, under /fileserver/bin/onstartup.d, that contains the following code :

base="scheduleScript execute /fileserver/bin/maintenance/locate.updatedb.rs \" \" today at 16:27"
GLOBALS.execCmd(base);

On startup I get the following java exeception : insufficient rights to execute script: 25024(where this Id is the script, named locate.updatedb.rs )

.............
mag 04, 2015 4:51:59 PM net.datenwerke.rs.scripting.service.scripting.ScriptingStartup$1 initialize
AVVERTENZA: javax.script.ScriptException: javax.script.ScriptException: net.datenwerke.security.service.security.exceptions.ViolatedSecurityException: Insufficient rights to execute script: 25024
net.datenwerke.rs.scripting.service.scripting.exceptions.ScriptEngineException: javax.script.ScriptException: javax.script.ScriptException: net.datenwerke.security.service.security.exceptions.ViolatedSecurityException: Insufficient rights to execute script: 25024
    at net.datenwerke.rs.scripting.service.scripting.engines.GroovyEngine.eval(GroovyEngine.java:67)
    at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.executeScript(ScriptingServiceImpl.java:207)
    at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.executeScript(ScriptingServiceImpl.java:253)
    at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.executeScript(ScriptingServiceImpl.java:301)
    at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.executeScript(ScriptingServiceImpl.java:272)
    at net.datenwerke.rs.scripting.service.scripting.ScriptingStartup$1.initialize(ScriptingStartup.java:97)
    at net.datenwerke.gf.service.lateinit.LateInitStartup$1.run(LateInitStartup.java:42)
    at java.lang.Thread.run(Unknown Source)
Caused by: javax.script.ScriptException: javax.script.ScriptException: net.datenwerke.security.service.security.exceptions.ViolatedSecurityException: Insufficient rights to execute script: 25024
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:138)
    at net.datenwerke.rs.scripting.service.scripting.engines.GroovyEngine.eval(GroovyEngine.java:65)
    ... 7 more
Caused by: javax.script.ScriptException: net.datenwerke.security.service.security.exceptions.ViolatedSecurityException: Insufficient rights to execute script: 25024
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:335)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:132)
    ... 8 more
Caused by: net.datenwerke.security.service.security.exceptions.ViolatedSecurityException: Insufficient rights to execute script: 25024
    at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.validateExecution(ScriptingServiceImpl.java:321)
    at net.datenwerke.rs.scripting.service.scripting.terminal.commands.ScheduleScriptExecuteSubCommand.execute(ScheduleScriptExecuteSubCommand.java:87)
    at net.datenwerke.rs.terminal.service.terminal.helpmessenger.HelpMessageInterceptor.invoke(HelpMessageInterceptor.java:54)
    at net.datenwerke.rs.terminal.service.terminal.hooks.SubCommandContainerImpl.execute(SubCommandContainerImpl.java:19)
    at net.datenwerke.rs.scripting.service.scripting.terminal.commands.ScheduleScriptCommand.execute(ScheduleScriptCommand.java:47)
    at net.datenwerke.rs.terminal.service.terminal.helpmessenger.HelpMessageInterceptor.invoke(HelpMessageInterceptor.java:54)
    at net.datenwerke.rs.terminal.service.terminal.ExecuteCommandConfigImpl.execute(ExecuteCommandConfigImpl.java:27)
    at net.datenwerke.rs.terminal.service.terminal.TerminalSession.execute(TerminalSession.java:147)
    at net.datenwerke.rs.terminal.service.terminal.TerminalSession.execute(TerminalSession.java:110)
    at net.datenwerke.rs.scripting.service.scripting.scriptservices.GlobalsWrapper.execCmd(GlobalsWrapper.java:184)
    at net.datenwerke.rs.scripting.service.scripting.scriptservices.GlobalsWrapper$execCmd.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
    at Script1.run(Script1.groovy:2)
    at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:332)
    ... 9 more

mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.BasicRepositoryResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.BasicRepositoryResource2 as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.BasicTagRepositoryResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.DataSourceResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.ExporterResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.OlapDiscoverResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.QueryResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.SessionResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.StatisticsResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory register
INFORMAZIONI: Registering net.datenwerke.rs.saiku.server.rest.resources.SaikuI18nResource as a root resource class
mag 04, 2015 4:51:59 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFORMAZIONI: Initiating Jersey application, version 'Jersey: 1.18.1 02/19/2014 03:28 AM'
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.BasicRepositoryResource to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.BasicRepositoryResource2 to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.BasicTagRepositoryResource to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.DataSourceResource to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.ExporterResource to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.OlapDiscoverResource to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.QueryResource to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.SessionResource to GuiceManagedComponentProvider with the scope "Singleton"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.StatisticsResource to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM com.sun.jersey.guice.spi.container.GuiceComponentProviderFactory getComponentProvider
INFORMAZIONI: Binding net.datenwerke.rs.saiku.server.rest.resources.SaikuI18nResource to GuiceManagedComponentProvider with the scope "PerRequest"
mag 04, 2015 4:52:00 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMAZIONI: Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\reportserver has finished in 32,802 ms
mag 04, 2015 4:52:00 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMAZIONI: Deploying web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT
mag 04, 2015 4:52:00 PM org.apache.catalina.startup.HostConfig deployDirectory
INFORMAZIONI: Deployment of web application directory C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT has finished in 196 ms
mag 04, 2015 4:52:00 PM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["http-bio-8080"]
mag 04, 2015 4:52:00 PM org.apache.coyote.AbstractProtocol start
INFORMAZIONI: Starting ProtocolHandler ["ajp-bio-8009"]
mag 04, 2015 4:52:00 PM org.apache.catalina.startup.Catalina start
INFORMAZIONI: Server startup in 40728 ms

So, it seems that first script , under onstartup.d, can't have rights to execute locate.updatedb.rs script?
How can I give the rights privileges to execute the second script?

Thanks again,
Alex

Offline

#4 2015-05-05 08:08:44

Arno Mittelbach
datenwerke
Registered: 2012-02-14

Re: Scripting.cf file

Hi Alex,

this is a bit tricky. The problem is that scheduleScript checks if the user is allowed to actually run the script. During onstartup, however, there is no user logged in and hence the security exception.
I would also be careful scheduling scripts automatically on startup, since this can lead to running scripts multiple times, if you restart the server. Anyhow, if you really want to do this, then the
easiest is to use the scheduler API directly. Here is what the scheduleScript command is doing

ScriptExecuteJob job = new ScriptExecuteJob();
job.setScript(file);
job.setArguments(scriptArg);
		
AbstractTrigger trigger = triggerService.parseExpression(expression);
if(null != trigger) 
	schedulerService.schedule(job, trigger);

Here triggerService is an instance of net.datenwerke.scheduler.service.scheduler.nlp.NlpTriggerService which parses strings like "today at 16:27" so you don't need to manually configure the trigger.

Cheers
-Arno

Offline

#5 2015-05-05 11:18:28

ralex
Member
Registered: 2015-04-20

Re: Scripting.cf file

Hi,
I put the following script under login.d (just to try it...I know it does not make sense) :

import net.datenwerke.rs.scripting.service.jobs.ScriptExecuteJob
import net.datenwerke.scheduler.service.scheduler.nlp.NlpTriggerService
import net.datenwerke.scheduler.service.scheduler.entities.AbstractTrigger
import net.datenwerke.rs.scripting.service.scripting.terminal.commands.ScheduleScriptExecuteSubCommand
import net.datenwerke.scheduler.service.scheduler.SchedulerService

ScriptExecuteJob job = new ScriptExecuteJob();
job.setScriptId(345);
//job.setArguments(scriptArg);

def triggerService = GLOBALS.getInstance(NlpTriggerService.class)
System.out.println(triggerService);
def schedulerService = GLOBALS.getInstance(SchedulerService.class)
System.out.println(schedulerService);

AbstractTrigger trigger = triggerService.parseExpression("today at 12:58");
System.out.println(trigger);

if(null != trigger) 
	schedulerService.schedule(job, trigger);

I don't have any error on catalina.log , but the script doesn't schedule the job (it should run "updatedb" command which is in the file whose id is 345 and then I should see on catalina log the rebuild index...).

Am I missing something in the code?

Thanks,
Alex

Offline

#6 2015-05-08 20:03:55

Arno Mittelbach
datenwerke
Registered: 2012-02-14

Re: Scripting.cf file

Hi Alex,

your script works perfectly for me. Did you execute it in commit mode ("-c")?

Cheers
-Arno

Offline

#7 2015-05-11 07:02:38

ralex
Member
Registered: 2015-04-20

Re: Scripting.cf file

Hi,
I don't think so... Where should I write down the -c option in the first script(that I sent on the previous post) or the second one which only contains the following instruction ......"GLOBALS.execCmd("updatedb");"?

Thanks again,

Alex


Update: I tried in the second script  in the following way : "GLOBALS.execCmd("-c updatedb") ...but I can't see any job scheduled...and any error.

Which table should contain this information in?

Last edited by ralex (2015-05-11 07:29:20)

Offline

#8 2015-05-11 07:34:13

Arno Mittelbach
datenwerke
Registered: 2012-02-14

Re: Scripting.cf file

Hi Alex,

sorry, I somehow missed that you want to do this in onlogin. I am afraid with the current version this won't work as the onlogin scripts are not executed in commit mode. We have changed this in the trunk and also the latest support version has picked up the change but it has not made it yet to the open source version. It will be in the next release but I can't yet say when this will be.

Regards
-Arno

Offline

Board footer

Powered by FluxBB