eridanibrew@gmail.com
Well-known member
OK, this is really stupid, but I can't figure it out.
I am looking to pass a command line argument to my script, for example to toggle a verbose logging flag. --help shows 2 possibilities, but I can't make either one work.
from help:
The run command loads and executes script files in the PixInsight JavaScript Runtime (PJSR) and core shell script engines.
Usage: run [<arg_list>] [<script_file_list>]
-a=<arg> | --argument=<arg>
Defines an argument that will be passed to the PJSR. Multiple instances
of this argument can be used to define an ordered list of script
arguments. The running script will have access to the list of arguments
through the jsArguments property of the Global JavaScript object.
-p=<id>,<value> | --parameter=<id>,<value>
Defines a parameter that will be passed to the PJSR. <id> and <value>
are the identifier and value, respectively, of a new script parameter.
If <id> has already been specified, its previous value is replaced.
Multiple instances of this argument can be used to define a list of
script parameters. The running script will have access to the passed
parameters with the get method of the Parameters core JavaScript
object. Note that for security reasons, script parameters are always
String objects. In this way, a script parameter cannot be used to
inject JavaScript code into PJSR.
Option 1
Tried to use a command line like
"C:\Program Files\PixInsight\bin\PixInsight.exe" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js" --argument="verbose"
"C:\Program Files\PixInsight\bin\PixInsight.exe" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js" -a=verbose
"C:\Program Files\PixInsight\bin\PixInsight.exe" --argument="verbose" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js"
"C:\Program Files\PixInsight\bin\PixInsight.exe" -a="verbose" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js"
Code:
for (var a in jsArguments)
{
console.writeln("argument is " + a);
}
This gives a popup message Unknown string argument: --argument=verbose.
Option 2
Used a command line like
"C:\Program Files\PixInsight\bin\PixInsight.exe" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js" --parameter=verbose,true
"C:\Program Files\PixInsight\bin\PixInsight.exe" --parameter=verbose,true -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js"
"C:\Program Files\PixInsight\bin\PixInsight.exe" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js" -p=verbose,true
"C:\Program Files\PixInsight\bin\PixInsight.exe" -p=verbose,true -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js"
...
Code:
var x = Parameters.get("verbose");
This gives a popup message Unknown string argument: --parameter=verbose,true.
After several hours of trying various combinations, this is apparently a truly difficult task. How can I pass some type of argument to my script?
Thanks,
brew
I am looking to pass a command line argument to my script, for example to toggle a verbose logging flag. --help shows 2 possibilities, but I can't make either one work.
from help:
The run command loads and executes script files in the PixInsight JavaScript Runtime (PJSR) and core shell script engines.
Usage: run [<arg_list>] [<script_file_list>]
-a=<arg> | --argument=<arg>
Defines an argument that will be passed to the PJSR. Multiple instances
of this argument can be used to define an ordered list of script
arguments. The running script will have access to the list of arguments
through the jsArguments property of the Global JavaScript object.
-p=<id>,<value> | --parameter=<id>,<value>
Defines a parameter that will be passed to the PJSR. <id> and <value>
are the identifier and value, respectively, of a new script parameter.
If <id> has already been specified, its previous value is replaced.
Multiple instances of this argument can be used to define a list of
script parameters. The running script will have access to the passed
parameters with the get method of the Parameters core JavaScript
object. Note that for security reasons, script parameters are always
String objects. In this way, a script parameter cannot be used to
inject JavaScript code into PJSR.
Option 1
Tried to use a command line like
"C:\Program Files\PixInsight\bin\PixInsight.exe" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js" --argument="verbose"
"C:\Program Files\PixInsight\bin\PixInsight.exe" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js" -a=verbose
"C:\Program Files\PixInsight\bin\PixInsight.exe" --argument="verbose" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js"
"C:\Program Files\PixInsight\bin\PixInsight.exe" -a="verbose" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js"
Code:
for (var a in jsArguments)
{
console.writeln("argument is " + a);
}
This gives a popup message Unknown string argument: --argument=verbose.
Option 2
Used a command line like
"C:\Program Files\PixInsight\bin\PixInsight.exe" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js" --parameter=verbose,true
"C:\Program Files\PixInsight\bin\PixInsight.exe" --parameter=verbose,true -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js"
"C:\Program Files\PixInsight\bin\PixInsight.exe" -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js" -p=verbose,true
"C:\Program Files\PixInsight\bin\PixInsight.exe" -p=verbose,true -n -r="D:\Dropbox\BrewSky\ACPHacks\PixInsight Scripts\Rotate\Flats\CalibFlatRotate.js"
...
Code:
var x = Parameters.get("verbose");
This gives a popup message Unknown string argument: --parameter=verbose,true.
After several hours of trying various combinations, this is apparently a truly difficult task. How can I pass some type of argument to my script?
Thanks,
brew