I am new to NSIS script. I want to send the version number to my test.nsi file
but it does not work. Inside my test.nsi file, the value of version is: test.nsi.
What is the correct syntax for this command?
"C:\Program Files\NSIS\makensis.exe" -DVERSION=1.2.1 test.nsi
thanks,
Jdang
The documentation is quite clear
http://nsis.sourceforge.net/Docs/Chapter3.html
You should be using a / rather than a - to prefix the parameter name so your command becomes
"C:\Program Files\NSIS\makensis.exe" /DVERSION=1.2.1 test.nsi
Related
For my actual creating intial server setup script i need to add a line thats saved in a variable after a specific line in a specific file.
I want to add the line:
zend_extension = $phpextensiondir/ioncube_loader_lin_$phpextensionnumber.so
after the following line:
;realpath_cache_ttl = 120
in the following files:
/etc/php/$phpversionnumber/cli/php.ini
/etc/php/$phpversionnumber/cli/fpm.ini
I was looking around, but can't find any what I understand. Actually I'm new to bash scripting.
Can anybody explain? It seems that sed is not the right choice for it?
awk '{print} $0=="old line"{print "new line"}' file
Is there a way to disable checks in puppet-lint using a configuration file as it is in rubocop? The configuration file should be a txt file, a json file or other formats?
Yes, the file is called .puppet-lint.rc and should look like this:
--fail-on-warnings
--relative
--no-class_inherits_from_params_class-check
--no-documentation-check
--no-single_quote_string_with_variables-check
It's a list of arguments that you would normally pass as command line arguments. For all checks see documentation.
I have an application calls the below command:
C:\Users\212340141>"C:\Program Files\Microsoft Office\Office14\excel.exe" /e "C:
\My Programs\CPU Analysis\data\IOParse.xlsm" "-iodumplocation"C:\My Programs\CPU
Analysis\iodump\065901_iodump.txt""
When I run this command, it opens excel, passing in the C:\My Programs\CPU Analysis\iodump\065901_iodump.txt path as a parameter for the excel book to use in the macros it runs automatically. The macros run correctly and the file is modified correctly, but I get the following errors when I run the command:
How can I get rid of the errors?
Answer
As mentioned in the accepted answer, excel was trying to open multiple files because of how I wrote the command. The way I solved this is I created a text file to hold the path I was trying to pass into the macro. The macro would open the text file and read the path to get the path it needed. This is much cleaner and easier than trying to get the path from the command line.
Description of the startup switches for Excel lists and describes the optional switches which can be used on starting Excel. /e is listed on this page written by Microsoft. But -iodumplocation is definitely not a command line switch for Excel.
Using double quotes within a double quoted string is always a mistake on command line and the result is unpredictable as depending on code of command line parser, see answer on Why double quotes should be always only at beginning and end of an argument string?
The command line used is obviously interpreted by Excel as
"C:\Program Files\Microsoft Office\Office14\excel.exe" /e "C:\My Programs\CPU Analysis\data\IOParse.xlsm" "-iodumplocation" C:\My Programs\CPU Analysis\iodump\065901_iodump.txt""
which results in
/e ... starting without displaying the startup screen and without the creation of a new workbook.
C:\My Programs\CPU Analysis\data\IOParse.xlsm ... opening this marco-enabled workbook file.
-iodumplocation ... the failed attempt to open a file with name -iodumplocation.xlsx in current working directory.
C:\My ... the failed attempt to open a file with name My.xlsx in root of drive C:.
Programs\CPU ... the failed attempt to open a file with name CPU.xlsx in subdirectory Programs of current working directory.
Analysis\iodump\065901_iodump.txt"" ... the failed attempt to open a file with invalid name 065901_iodump.txt"" in subdirectory Analysis\iodump of current working directory.
I can't suggest a correct command line as I don't know what -iodumplocation should be.
I want to read some values from a file (config.json) into some variables when I compile my nsis script.
How can I possibly do that?
Thanks in advance.
The !include command can include any file (at compile time) at the point where it is placed in the nsis script. But the included file must be compliant with the nsis syntax (e.g. it should !define some values).
The !execute command could help you: if you need absolutely to process a json file you could code a third-party batch command file to pre-process the json file and translate it into a suitable nsis file.
You can use !define to pass some value which can be used in compile time. For example lets imagine that you have got this code in you nsis source file:
!define PATHTOFILE "C:\thisfilewillbedeleted.ext"
Delete $PATHTOFILE
If you want to change this walue on compile time you can call nsis in this way:
makensis /DPATHTOFILE="C:\otherfiletodelete.ext"
[EDIT]
If you got *.json file which is generated using external tool and you must use this kind of file I will suggest you to use some building system, for example ant. You can create build.xml which read, parse data from json file and then write those data to *.nsh file. I think it will be better and cleaner than do it all in nsis script.
If you just need to parse your json file on runtime, you can use !define with the /file option:
!define /file OPTIONS json.txt
It will define OPTIONS with the content of json.txt.
If you want to utilize your json file in compile time to alter the generated exe, then you need some kind of precompiler, which is what you're actually doing.
You may use the !searchparse command with the /file switch.
Example :
# search filename.cpp for a line '#define APP_VERSION "2.5"' and set ${VER_MAJOR} to 2, ${VER_MINOR} to 5.
!searchparse /file filename.cpp `#define APP_VERSION "` VER_MAJOR `.` VER_MINOR `"`
I am trying to make my setups scripts modular. I am calling setup exe's from within main setup script based to the requirements. I want to pass command line arguments to the exe being called. Can someone please tell me how to access the command line arguments in the script being called.
Thanks in advance.
you can use GetOptions function (FileFunc.nsh must be included above). Following example shows p parameter reading; its value is saved into the variable. $CMDLINE is your command line (absolute or relative, as you called) containing also your parameters.
!include FileFunc.nsh
Var variable
${GetOptions} $CMDLINE "/p" $variable
Try to get options from Command line by their name:
http://nsis.sourceforge.net/Get_command_line_parameter_by_name