I am trying to set a DOS variable like this.
set MPATH = "$MYSQL_PATH"
Here $MYSQL_PATH comes from a different context. The problem is that the variable MPATH never gets set. If I say echo "$MYSQL_PATH", then it properly prints the value contained in $MYSQL_PATH. But when I use echo "%MPATH%" nothing gets printed. Why am I not able to assign the value to MPATH when there is value in $MYSQL_PATH.
regards,
nirvan
Comments
set MPATH=%MYSQL_PATH%
Then you can use echo "%MPATH%" or echo %MPATH% to print it.
regards,
nirvan.
regards,
nirvan.
[code]
if defined MYSQL_PATH goto isdefined
[color=Grey]or:[/color]
set MPATH=%MYSQL_PATH%
if defined MPATH goto isdefined
[color=Grey]or:[/color]
set MPATH=%MYSQL_PATH%
if not "%MPATH%"=="" goto isdefined
[/code]
If MYSQL_PATH isn't defined, then "set MPATH=%MYSQL_PATH%" is equivalent to "set MPATH=", which undefines MPATH.
One other thing. Although the principles are the same, a Windows command prompt is not a DOS command prompt.
regards,
nirvan.
What's confusing is you're saying it's a DOS batch file. I don't know if you're confusing it for a linux shell script or a windows batch script, but what I know is that there is no MySQL for DOS. You said using dollar signs around MYSQL_PATH fixed the first problem, so why does that suddenly not work now?
I am using [link=http://izpack.org/features/]IzPack Installer[/link], which is used to package and install java applications on any target computer. Its just a software that helps on distribute custom java applications.
When using Izpack, Izpack has its own set of [link=http://izpack.org/documentation/installation-files.html#variable-substitution]variables[/link] (or even user defined) which can be used in any file that is marked as parsable. At run time, these variables will be substituted with actual values by the Izpack parsing system. These variables are referred by syntax $VARIABLE ($ sign prefixing the variable name). Note that it has got nothing to do with the unix/linux variables
So in my case I have a DOS batch file (createDB.bat) marked as parsable,which contains $MYSQL_PATH as an Izpack variable. Now at run time, before the batch file is run, the Iapack variable substitution system, parses the $MYSQL_PATH variable and replaces it with actual value(for example "C: emp"). I don't know what value is substituted when $MYSQL_PATH is empty.
I said earlier that things worked because, I didn't test it exhaustively. I had to decide what code to execute depending on whether $MYSQL_PATH is empty or has some value. I tested it for empty but not if it had some value. Thus I had a false impression that everything worked well.
Anyway you have helped me out to solve half the problem. Thanks a lot for that. I hope you have a fair idea of what I am trying to achieve
regards,
nirvan.