Running Scripts from the command line

Top  Previous  Next

You can run scripts from the command line, just by typing the paths where the Mnova .exe file and the script are located and -sf "name of the script function": "mestrenovaPathname" "scriptPathname" -sf "scriptFunctionToRun"

 

For example:

 

1. mestrenova scriptPath

For example: mestrenova c:\temp\multiOpen.qs will run the function multiOpen() from multiOpen.qs file, i.e. it runs a function with the same file name.

 

2. mestrenova scriptPath -sf functionName,arg1,arg2,...,argN

This runs functionName(arg1, arg2, ... argN) from the scriptPath file.

 

The below command line is doing the same as the above one:

  mestrenova -sf functionName,arg1,arg2,...,argN scriptPath

 

Examples:

You can also use: "mestrenovaPath" "scriptPath" -sf "scriptFunctionToRun"

 

"C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" "C:\Program Files\Mestrelab Research S.L\MestReNova\scripts\myScript.qs" -sf "myFunction"

It is also possible to specify arguments:

 

"C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" "C:\Program Files\Mestrelab Research S.L\MestReNova\scripts\myScript.qs" -sf "myFunction",0.1,10,true,off

 

In this case, MNova will run myFunction(0.1,10,true,"off") from myScript.qs with the arguments specified. No spaces after commas!

 

3. mestrenova -sf functionName,arg1,arg2,...argN

 

In this case it is supposed that the function functionName is taken from one of the script directories, either MNova standard or user defined.

 

Note: Command line arguments are separated with white-spaces. This is why it is important not to use white-spaces after commas. If script arguments contain white-spaces then use quotes: "C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" -sf openSpecWithMols,"C:\1H\fid".

 

This doesn't need quotes: "C:\Program Files\Mestrelab Research S.L\MestReNova\MestReNova.exe" -sf openSpecWithMols,C:\1H\fid

 

Complex case example:

mestrenova specPath1 specPath2 -sf functionName,arg1,arg2 specPath3 specPath4

 

This will first open the spectra specPath1, specPath2, specPath3, specPath4. Next, apply the script: functionName(arg1, arg2)

 

 

There is also a single command line parameter -w (w stands for wait). If this parameter is present in the command line and there is no Mnova already running, then Mnova will open, load any files and run any scripts passed in the command line and, finally, it will close.

 

If this parameter is present but Mnova is already running, then the second Mnova instance will pass the command line information to the first running instance, the first running will load/run files/scripts and finally it will notify to the second instance that it has finished, so the second instance will close.

 

Some examples:

 

MestReNova.exe -w

Mnova not running: Mnova opens and closes immediately.

Mnova running: The second Mnova instance will return immediately.

 

MestReNova.exe myscript.qs -w

Mnova not running: Mnova opens run the myscript function in the myscript.qs file and closes when it finishes.

Mnova running: A second Mnova instance is run and passes the parameters to the already running one. The myscript function from the myscript.qs file is run in the already running Mnova instance and when it finishes, notifies the second one and the second one Mnova instance (the one you have started from the command line) it closes.