Book a Demo

Author Topic: Is there a way to run scripts on the fly?  (Read 11341 times)

motivatedgorilla

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Is there a way to run scripts on the fly?
« on: February 19, 2014, 06:21:51 am »
Rather than create a script, execute it and then delete it, is there a way to run them on the fly i.e. execute and discard. The reason is the because i don't want people who don't have authority to execute them.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #1 on: February 19, 2014, 07:47:50 am »
You could run then via a batch script locally on your disk.

q.

motivatedgorilla

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #2 on: February 19, 2014, 07:50:24 am »
Quote
You could run then via a batch script locally on your disk.

q.
You mean a batch file? Don't believe a batch file can execute Javascript.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #3 on: February 19, 2014, 09:16:43 am »
You'll end up using JScript or VBScript instead of Javascript, but have a look at http://answers.yahoo.com/question/index?qid=20090717063113AAEzenT

The main difference is that you'll need to create the repository instance and explicitly use it instead of implicitly having its namespace available.

Of course you don't need a batch file to run it, with an appropriate extension a double click will run it.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #4 on: February 19, 2014, 09:16:51 am »
Probably not. You did not mention that in the OP. But isn't there some interpreter that understands it?

q.

motivatedgorilla

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #5 on: February 19, 2014, 10:14:02 am »
Quote
You'll end up using JScript or VBScript instead of Javascript, but have a look at http://answers.yahoo.com/question/index?qid=20090717063113AAEzenT

The main difference is that you'll need to create the repository instance and explicitly use it instead of implicitly having its namespace available.

Of course you don't need a batch file to run it, with an appropriate extension a double click will run it.

Thanks Simon. Is there an example of creating a repository instance that i can refer to? Secondly, is there a way to restrict whom can run the scripts within Sparx?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #6 on: February 19, 2014, 08:34:03 pm »
You can't restrict it. Event if you remove the DLL for the API it can be downloaded from the free EA Viewer. And finally the database is open to SQL for any user.

q.

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #7 on: February 19, 2014, 08:57:52 pm »
Code: [Select]
'Sample Code to create a repository object
Dim r As EA.Repository
r = New EA.Repository
r.OpenFile(<<EAP File path>> / <<Connection String>>)

Code: [Select]
'Sample code to initialize a script control and pass it as arg to invoke from cmd prompt
Dim SC As New ScriptControl
SC.AddObject("Repository", Repository, True)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #8 on: February 19, 2014, 09:27:31 pm »
That looks rather like VB. The OP wanted JavaScript...

q.

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #9 on: February 19, 2014, 10:03:49 pm »
Oops.. thought they already zeroed in on VBScript / JScript...

Quote
You'll end up using JScript or VBScript instead of Javascript

motivatedgorilla

  • EA User
  • **
  • Posts: 44
  • Karma: +0/-0
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #10 on: February 20, 2014, 05:12:05 am »
Quote
Oops.. thought they already zeroed in on VBScript / JScript...

Quote
You'll end up using JScript or VBScript instead of Javascript

What do you mean by zeroed in?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #11 on: February 20, 2014, 08:44:48 am »
Javascript more than likely won't be able to create an activex object for EA. There are ways to do it internally to EA, but not pure Javascript. Which is why I said that it would be JScript or VBScript. And the difference between them is just syntax.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #12 on: February 20, 2014, 08:16:53 pm »
Hi,

Within EA; your script can check the group that the user is within (if you have security enabled) and stop if they are not in a permitted group. From memory i think there are some methods on the repository class for this.

Regards,

Jon.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #13 on: February 20, 2014, 09:09:07 pm »
Quote
Hi,

Within EA; your script can check the group that the user is within (if you have security enabled) and stop if they are not in a permitted group. From memory i think there are some methods on the repository class for this.

Regards,

Jon.

I don't see any security option to disable writing/executing scripts on your own.

q.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Is there a way to run scripts on the fly?
« Reply #14 on: February 21, 2014, 02:48:20 am »
Your right there isn't. But you can add a check into the beginning of a script that terminates the script if the user is not in the appropriate group...