Persisting env vars in cmd windows

R

Richard

I've got a .bat file that sets a number of symbols (environment vars)
that are useful in a number of other command windows associated with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the new cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd window and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter at the
beginning of every other utility file. I tried this by using "cmd /c
symbol-setter.bat" to no avail. I believe that fails because the "cmd
/c" command starts a new session in which to set local env. vars and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a .reg file
appropriate to each project in which I want persistant env. vars, thus
only needing to invoke that once at the inception of a project, maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard
 
P

Pegasus \(MVP\)

Richard said:
I've got a .bat file that sets a number of symbols (environment vars)
that are useful in a number of other command windows associated with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the new cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd window and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter at the
beginning of every other utility file. I tried this by using "cmd /c
symbol-setter.bat" to no avail. I believe that fails because the "cmd
/c" command starts a new session in which to set local env. vars and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a .reg file
appropriate to each project in which I want persistant env. vars, thus
only needing to invoke that once at the inception of a project, maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard

It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
G

GO

Hi Richard,

Are these variables you are setting static or dynamic? That is are the
values changing through out the batch file and do those new values need be
be available to the other batch files? If the values are static, which is
what it sounds like, then you simply need to "call" the batch file containg
your "symbol-setter". So at the beginning of your utility batch file you
would have a line:
call <symbol-setter>.bat
where <symbol-setter> is the name of your batch file. If said batch file is
not located in your search path then you will have to specify the full path
to it's location (eg: C:\batchfiles\symbol-setter.bat).

If your variables are dynamic then you will most likely have to create a
temporary batch file that echos the variables and values and call that as
needed. There may be a more elegant way to do that but I'm not sure.

HTH,

Greg
 
R

Richard

Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to work
on the Prmp project, I open several Command windows in succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step 1 and
follow that with a command step 2 with a different batch command, e.g.
C160_StartBreakpointer.bat, which starts a listener for any breakpoint
command executed in my Ruby/Rails application and starts an interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs to me that
I can install an invocation of the followin line at the start of all my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy way to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat
--------------------------------------------------------------------------------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat
--------------------------------------------------------------------------------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT
 
R

Richard

Hi GO,

I think you're right. I just realized that as I was documenting a
detailed response to Pegasus. It's midnight, my time, right now, so
I'll try that out tomorrow.

Regards,
Richard
 
P

Pegasus \(MVP\)

Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


Richard said:
Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to work
on the Prmp project, I open several Command windows in succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step 1 and
follow that with a command step 2 with a different batch command, e.g.
C160_StartBreakpointer.bat, which starts a listener for any breakpoint
command executed in my Ruby/Rails application and starts an interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs to me that
I can install an invocation of the followin line at the start of all my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy way to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat
-------------------------------------------------------------------------- ------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat
-------------------------------------------------------------------------- ------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
R

Richard

Hi Pegasus,

OK, I've simplified these scripts substantially, e.g.

C130_StartLocalWebServer.bat
(down to 8 lines instead of 20 because the error checking no longer
needed)
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

That's just what I wanted.

I appreciate the observations you made, i.e.:
1. Checking for existence of %2 obviates the need to check for %1
2. :EOF is built-in, obviating the need to define a symbol at the end
of the script

Mainly, I rely on 3 of my ~20 batch commands to start-up testing a
Ruby/Rails app. I keep those command windows open for the duration of
a testing/developing session.

Heretofore, I opened three command windows and exectuted two bath
commands in each.
With your help, I've cut that down to one command in each.

Is there a way to combine that into a single batch command, e.g.

CombineCommand.bat (pseudocode)
---------------------------------
run cmd.exe; execute batch1.bat
run cmd.exe; execute batch2.bat
run cmd.exe; execute batch3.bat

and achieve the same result I'm getting now?

Again, thanks for your help.

Regards,
Richard

Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


Richard said:
Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to work
on the Prmp project, I open several Command windows in succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step 1 and
follow that with a command step 2 with a different batch command, e.g.
C160_StartBreakpointer.bat, which starts a listener for any breakpoint
command executed in my Ruby/Rails application and starts an interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs to me that
I can install an invocation of the followin line at the start of all my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy way to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat
-------------------------------------------------------------------------- ------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat
-------------------------------------------------------------------------- ------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

I've got a .bat file that sets a number of symbols (environment vars)
that are useful in a number of other command windows associated with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the new cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd window and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter at the
beginning of every other utility file. I tried this by using "cmd /c
symbol-setter.bat" to no avail. I believe that fails because the "cmd
/c" command starts a new session in which to set local env. vars and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a .reg file
appropriate to each project in which I want persistant env. vars, thus
only needing to invoke that once at the inception of a project, maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard


It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
P

Pegasus \(MVP\)

When you ask about combining your various batch files
into the one file then you're spot on. The general idea is:
- Have all code for the one project in one single batch file.
- Make it highly structured.
- Avoid spaghetti code.
- Set global variables.
- Add lots of comments.

If you adhere to these rules then you will find that your
batch files become much more robust and are very easy
to maintain. You also skirt around the environmental variable
issue that triggered this thread.

I have seen contiguous (rather than modular) batch files that
extend over 300 lines, with numerous goto statements that
resemble the path taken by a hare in full flight. They are almost
impossible to maintain. In a structured form even a beginner
could debug and modify them.

Here is how I structure all my batch files:
=============================
@echo off
goto Start
--------------------------------------------
Program description:
Parameters:
Prerequisites:
Version:
Author:
Date:
--------------------------------------------
:Start
set SourceDir=D:\Some Folder
set TargetDir=E:\Other folder
call :Sub1
call :Sub2 %name%
if /i "%result%"==OK call :Sub3
goto :eof

--------------------------------------------
Some comments about Sub1
--------------------------------------------
:Sub1
Code for Sub1
goto :eof

--------------------------------------------
Some comments about Sub2
--------------------------------------------
:Sub2
Code for Sub2
goto :eof


Richard said:
Hi Pegasus,

OK, I've simplified these scripts substantially, e.g.

C130_StartLocalWebServer.bat
(down to 8 lines instead of 20 because the error checking no longer
needed)
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

That's just what I wanted.

I appreciate the observations you made, i.e.:
1. Checking for existence of %2 obviates the need to check for %1
2. :EOF is built-in, obviating the need to define a symbol at the end
of the script

Mainly, I rely on 3 of my ~20 batch commands to start-up testing a
Ruby/Rails app. I keep those command windows open for the duration of
a testing/developing session.

Heretofore, I opened three command windows and exectuted two bath
commands in each.
With your help, I've cut that down to one command in each.

Is there a way to combine that into a single batch command, e.g.

CombineCommand.bat (pseudocode)
---------------------------------
run cmd.exe; execute batch1.bat
run cmd.exe; execute batch2.bat
run cmd.exe; execute batch3.bat

and achieve the same result I'm getting now?

Again, thanks for your help.

Regards,
Richard

Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to work
on the Prmp project, I open several Command windows in succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step 1 and
follow that with a command step 2 with a different batch command, e.g.
C160_StartBreakpointer.bat, which starts a listener for any breakpoint
command executed in my Ruby/Rails application and starts an interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs to me that
I can install an invocation of the followin line at the start of all my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy way to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat
--------------------------------------------------------------------------
------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat
--------------------------------------------------------------------------
------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT


Pegasus (MVP) wrote:
I've got a .bat file that sets a number of symbols (environment vars)
that are useful in a number of other command windows associated with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the new cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd
window
and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter at the
beginning of every other utility file. I tried this by using "cmd /c
symbol-setter.bat" to no avail. I believe that fails because the "cmd
/c" command starts a new session in which to set local env. vars and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a .reg file
appropriate to each project in which I want persistant env. vars, thus
only needing to invoke that once at the inception of a project, maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard


It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
R

Richard

Hi Pegasus,

Great batch template! Thanks.

I tested all the features. I was surprised by a couple of things,
like the "/i" switch and the use of OK without surrounding quotes.

But the piece de resistance was the "start" command, which you
mentioned earlier but I hadn't picked up on right away. Along with the
other improvements, I got to it now and got exactly what I've got
exactly what I want:

Startup.bat
----------------
START "BAT1 Commands" Bat1.bat
START "BAT2 Commands" Bat2.bat
: etc

let's me double-click its name and get precisely the command windows I
want to support my Ruby/Rails application development efforts.

It's embarrassing to admit that I've used Windows' bat files for
decades but never noticed some of the features you've mentioned.
Again, thanks for your expert help.

Best wishes,
Richard
When you ask about combining your various batch files
into the one file then you're spot on. The general idea is:
- Have all code for the one project in one single batch file.
- Make it highly structured.
- Avoid spaghetti code.
- Set global variables.
- Add lots of comments.

If you adhere to these rules then you will find that your
batch files become much more robust and are very easy
to maintain. You also skirt around the environmental variable
issue that triggered this thread.

I have seen contiguous (rather than modular) batch files that
extend over 300 lines, with numerous goto statements that
resemble the path taken by a hare in full flight. They are almost
impossible to maintain. In a structured form even a beginner
could debug and modify them.

Here is how I structure all my batch files:
=============================
@echo off
goto Start
--------------------------------------------
Program description:
Parameters:
Prerequisites:
Version:
Author:
Date:
--------------------------------------------
:Start
set SourceDir=D:\Some Folder
set TargetDir=E:\Other folder
call :Sub1
call :Sub2 %name%
if /i "%result%"==OK call :Sub3
goto :eof

--------------------------------------------
Some comments about Sub1
--------------------------------------------
:Sub1
Code for Sub1
goto :eof

--------------------------------------------
Some comments about Sub2
--------------------------------------------
:Sub2
Code for Sub2
goto :eof


Richard said:
Hi Pegasus,

OK, I've simplified these scripts substantially, e.g.

C130_StartLocalWebServer.bat
(down to 8 lines instead of 20 because the error checking no longer
needed)
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

That's just what I wanted.

I appreciate the observations you made, i.e.:
1. Checking for existence of %2 obviates the need to check for %1
2. :EOF is built-in, obviating the need to define a symbol at the end
of the script

Mainly, I rely on 3 of my ~20 batch commands to start-up testing a
Ruby/Rails app. I keep those command windows open for the duration of
a testing/developing session.

Heretofore, I opened three command windows and exectuted two bath
commands in each.
With your help, I've cut that down to one command in each.

Is there a way to combine that into a single batch command, e.g.

CombineCommand.bat (pseudocode)
---------------------------------
run cmd.exe; execute batch1.bat
run cmd.exe; execute batch2.bat
run cmd.exe; execute batch3.bat

and achieve the same result I'm getting now?

Again, thanks for your help.

Regards,
Richard

Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to work
on the Prmp project, I open several Command windows in succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step 1 and
follow that with a command step 2 with a different batch command, e.g.
C160_StartBreakpointer.bat, which starts a listener for any breakpoint
command executed in my Ruby/Rails application and starts an interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs to me that
I can install an invocation of the followin line at the start of all my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy way to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat
--------------------------------------------------------------------------
------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat
--------------------------------------------------------------------------
------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT


Pegasus (MVP) wrote:
message
I've got a .bat file that sets a number of symbols (environment vars)
that are useful in a number of other command windows associated with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the new cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd window
and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter at the
beginning of every other utility file. I tried this by using "cmd /c
symbol-setter.bat" to no avail. I believe that fails because the "cmd
/c" command starts a new session in which to set local env. vars and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a .reg file
appropriate to each project in which I want persistant env. vars, thus
only needing to invoke that once at the inception of a project, maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard


It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
P

Pegasus \(MVP\)

Thanks for the feedback. You'll probably find out a lot
more about batch files as you go on, especially when it
comes to the "set" and "for" commands. Try this from
a Command Prompt just for fun:

echo Today is %date:~0,3%
or
echo The time is %time::=.%

About testing equality without surrounding quotes or brackets

if %result%==OK

you must make sure that neither side of the = sign is ever blank.
If there is the slightest possibility, add some extra characters.
If you don't then the batch file will fail.

Richard said:
Hi Pegasus,

Great batch template! Thanks.

I tested all the features. I was surprised by a couple of things,
like the "/i" switch and the use of OK without surrounding quotes.

But the piece de resistance was the "start" command, which you
mentioned earlier but I hadn't picked up on right away. Along with the
other improvements, I got to it now and got exactly what I've got
exactly what I want:

Startup.bat
----------------
START "BAT1 Commands" Bat1.bat
START "BAT2 Commands" Bat2.bat
: etc

let's me double-click its name and get precisely the command windows I
want to support my Ruby/Rails application development efforts.

It's embarrassing to admit that I've used Windows' bat files for
decades but never noticed some of the features you've mentioned.
Again, thanks for your expert help.

Best wishes,
Richard
When you ask about combining your various batch files
into the one file then you're spot on. The general idea is:
- Have all code for the one project in one single batch file.
- Make it highly structured.
- Avoid spaghetti code.
- Set global variables.
- Add lots of comments.

If you adhere to these rules then you will find that your
batch files become much more robust and are very easy
to maintain. You also skirt around the environmental variable
issue that triggered this thread.

I have seen contiguous (rather than modular) batch files that
extend over 300 lines, with numerous goto statements that
resemble the path taken by a hare in full flight. They are almost
impossible to maintain. In a structured form even a beginner
could debug and modify them.

Here is how I structure all my batch files:
=============================
@echo off
goto Start
--------------------------------------------
Program description:
Parameters:
Prerequisites:
Version:
Author:
Date:
--------------------------------------------
:Start
set SourceDir=D:\Some Folder
set TargetDir=E:\Other folder
call :Sub1
call :Sub2 %name%
if /i "%result%"==OK call :Sub3
goto :eof

--------------------------------------------
Some comments about Sub1
--------------------------------------------
:Sub1
Code for Sub1
goto :eof

--------------------------------------------
Some comments about Sub2
--------------------------------------------
:Sub2
Code for Sub2
goto :eof


Hi Pegasus,

OK, I've simplified these scripts substantially, e.g.

C130_StartLocalWebServer.bat
(down to 8 lines instead of 20 because the error checking no longer
needed)
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

That's just what I wanted.

I appreciate the observations you made, i.e.:
1. Checking for existence of %2 obviates the need to check for %1
2. :EOF is built-in, obviating the need to define a symbol at the end
of the script

Mainly, I rely on 3 of my ~20 batch commands to start-up testing a
Ruby/Rails app. I keep those command windows open for the duration of
a testing/developing session.

Heretofore, I opened three command windows and exectuted two bath
commands in each.
With your help, I've cut that down to one command in each.

Is there a way to combine that into a single batch command, e.g.

CombineCommand.bat (pseudocode)
---------------------------------
run cmd.exe; execute batch1.bat
run cmd.exe; execute batch2.bat
run cmd.exe; execute batch3.bat

and achieve the same result I'm getting now?

Again, thanks for your help.

Regards,
Richard


Pegasus (MVP) wrote:
Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to work
on the Prmp project, I open several Command windows in succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step 1 and
follow that with a command step 2 with a different batch command, e.g.
C160_StartBreakpointer.bat, which starts a listener for any breakpoint
command executed in my Ruby/Rails application and starts an interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs to me
that
I can install an invocation of the followin line at the start of
all
my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy way to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat
--------------------------------------------------------------------------
------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat
--------------------------------------------------------------------------
------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT


Pegasus (MVP) wrote:
message
I've got a .bat file that sets a number of symbols
(environment
vars)
that are useful in a number of other command windows
associated
with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the new cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd window
and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter at the
beginning of every other utility file. I tried this by using
"cmd
/c
symbol-setter.bat" to no avail. I believe that fails because
the
"cmd
/c" command starts a new session in which to set local env.
vars
and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a
..reg
file
appropriate to each project in which I want persistant env.
vars,
thus
only needing to invoke that once at the inception of a
project,
maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard


It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
R

Richard

Hi Pegasus,
echo Today is %date:~0,3%
echo The time is %time::=.%

Thanks for the additional "toys". I've recorded them in my test folder
K:\_Projects\CmdScripts\Time&Date and tested them.

I've got perhaps a dozen sites (half from Microsoft) on command
scripts, but I didn't spot any documentation on this specific syntax.
Can you point me to an on-line source?
you must make sure that neither side of the = sign is ever blank.

Duly noted. Thanks.

Regarding starting up several command windows with Start commands,
being able to set the captions in those windows is very helpful. When
I set them up manually before, I only had useful captions on windows
that were active running some command, e.g. the Ruby/Rails logger or
MySQL.

Again, many thanks for your advice.

Best wishes,
Richard

Thanks for the feedback. You'll probably find out a lot
more about batch files as you go on, especially when it
comes to the "set" and "for" commands. Try this from
a Command Prompt just for fun:

echo Today is %date:~0,3%
or
echo The time is %time::=.%

About testing equality without surrounding quotes or brackets

if %result%==OK

you must make sure that neither side of the = sign is ever blank.
If there is the slightest possibility, add some extra characters.
If you don't then the batch file will fail.

Richard said:
Hi Pegasus,

Great batch template! Thanks.

I tested all the features. I was surprised by a couple of things,
like the "/i" switch and the use of OK without surrounding quotes.

But the piece de resistance was the "start" command, which you
mentioned earlier but I hadn't picked up on right away. Along with the
other improvements, I got to it now and got exactly what I've got
exactly what I want:

Startup.bat
----------------
START "BAT1 Commands" Bat1.bat
START "BAT2 Commands" Bat2.bat
: etc

let's me double-click its name and get precisely the command windows I
want to support my Ruby/Rails application development efforts.

It's embarrassing to admit that I've used Windows' bat files for
decades but never noticed some of the features you've mentioned.
Again, thanks for your expert help.

Best wishes,
Richard
When you ask about combining your various batch files
into the one file then you're spot on. The general idea is:
- Have all code for the one project in one single batch file.
- Make it highly structured.
- Avoid spaghetti code.
- Set global variables.
- Add lots of comments.

If you adhere to these rules then you will find that your
batch files become much more robust and are very easy
to maintain. You also skirt around the environmental variable
issue that triggered this thread.

I have seen contiguous (rather than modular) batch files that
extend over 300 lines, with numerous goto statements that
resemble the path taken by a hare in full flight. They are almost
impossible to maintain. In a structured form even a beginner
could debug and modify them.

Here is how I structure all my batch files:
=============================
@echo off
goto Start
--------------------------------------------
Program description:
Parameters:
Prerequisites:
Version:
Author:
Date:
--------------------------------------------
:Start
set SourceDir=D:\Some Folder
set TargetDir=E:\Other folder
call :Sub1
call :Sub2 %name%
if /i "%result%"==OK call :Sub3
goto :eof

--------------------------------------------
Some comments about Sub1
--------------------------------------------
:Sub1
Code for Sub1
goto :eof

--------------------------------------------
Some comments about Sub2
--------------------------------------------
:Sub2
Code for Sub2
goto :eof


Hi Pegasus,

OK, I've simplified these scripts substantially, e.g.

C130_StartLocalWebServer.bat
(down to 8 lines instead of 20 because the error checking no longer
needed)
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

That's just what I wanted.

I appreciate the observations you made, i.e.:
1. Checking for existence of %2 obviates the need to check for %1
2. :EOF is built-in, obviating the need to define a symbol at the end
of the script

Mainly, I rely on 3 of my ~20 batch commands to start-up testing a
Ruby/Rails app. I keep those command windows open for the duration of
a testing/developing session.

Heretofore, I opened three command windows and exectuted two bath
commands in each.
With your help, I've cut that down to one command in each.

Is there a way to combine that into a single batch command, e.g.

CombineCommand.bat (pseudocode)
---------------------------------
run cmd.exe; execute batch1.bat
run cmd.exe; execute batch2.bat
run cmd.exe; execute batch3.bat

and achieve the same result I'm getting now?

Again, thanks for your help.

Regards,
Richard


Pegasus (MVP) wrote:
Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


message
Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to
work
on the Prmp project, I open several Command windows in succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step 1 and
follow that with a command step 2 with a different batch command, e.g.
C160_StartBreakpointer.bat, which starts a listener for any breakpoint
command executed in my Ruby/Rails application and starts an
interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs to me
that
I can install an invocation of the followin line at the start of all
my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy way to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat

--------------------------------------------------------------------------
------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat

--------------------------------------------------------------------------
------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT


Pegasus (MVP) wrote:
message
I've got a .bat file that sets a number of symbols (environment
vars)
that are useful in a number of other command windows associated
with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the new cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd
window
and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter at the
beginning of every other utility file. I tried this by using "cmd
/c
symbol-setter.bat" to no avail. I believe that fails because the
"cmd
/c" command starts a new session in which to set local env. vars
and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a .reg
file
appropriate to each project in which I want persistant env. vars,
thus
only needing to invoke that once at the inception of a project,
maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard


It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
P

Pegasus \(MVP\)

The syntax for the two sample commands is visible when you type

set /?

even though it applies to any command, e.g. echo, copy,
del etc.

Similarly the syntax for the extremely powerful "for" command
is visible when you type

for /?

Richard said:
Hi Pegasus,
echo Today is %date:~0,3%
echo The time is %time::=.%

Thanks for the additional "toys". I've recorded them in my test folder
K:\_Projects\CmdScripts\Time&Date and tested them.

I've got perhaps a dozen sites (half from Microsoft) on command
scripts, but I didn't spot any documentation on this specific syntax.
Can you point me to an on-line source?
you must make sure that neither side of the = sign is ever blank.

Duly noted. Thanks.

Regarding starting up several command windows with Start commands,
being able to set the captions in those windows is very helpful. When
I set them up manually before, I only had useful captions on windows
that were active running some command, e.g. the Ruby/Rails logger or
MySQL.

Again, many thanks for your advice.

Best wishes,
Richard

Thanks for the feedback. You'll probably find out a lot
more about batch files as you go on, especially when it
comes to the "set" and "for" commands. Try this from
a Command Prompt just for fun:

echo Today is %date:~0,3%
or
echo The time is %time::=.%

About testing equality without surrounding quotes or brackets

if %result%==OK

you must make sure that neither side of the = sign is ever blank.
If there is the slightest possibility, add some extra characters.
If you don't then the batch file will fail.

Hi Pegasus,

Great batch template! Thanks.

I tested all the features. I was surprised by a couple of things,
like the "/i" switch and the use of OK without surrounding quotes.

But the piece de resistance was the "start" command, which you
mentioned earlier but I hadn't picked up on right away. Along with the
other improvements, I got to it now and got exactly what I've got
exactly what I want:

Startup.bat
----------------
START "BAT1 Commands" Bat1.bat
START "BAT2 Commands" Bat2.bat
: etc

let's me double-click its name and get precisely the command windows I
want to support my Ruby/Rails application development efforts.

It's embarrassing to admit that I've used Windows' bat files for
decades but never noticed some of the features you've mentioned.
Again, thanks for your expert help.

Best wishes,
Richard

Pegasus (MVP) wrote:
When you ask about combining your various batch files
into the one file then you're spot on. The general idea is:
- Have all code for the one project in one single batch file.
- Make it highly structured.
- Avoid spaghetti code.
- Set global variables.
- Add lots of comments.

If you adhere to these rules then you will find that your
batch files become much more robust and are very easy
to maintain. You also skirt around the environmental variable
issue that triggered this thread.

I have seen contiguous (rather than modular) batch files that
extend over 300 lines, with numerous goto statements that
resemble the path taken by a hare in full flight. They are almost
impossible to maintain. In a structured form even a beginner
could debug and modify them.

Here is how I structure all my batch files:
=============================
@echo off
goto Start
--------------------------------------------
Program description:
Parameters:
Prerequisites:
Version:
Author:
Date:
--------------------------------------------
:Start
set SourceDir=D:\Some Folder
set TargetDir=E:\Other folder
call :Sub1
call :Sub2 %name%
if /i "%result%"==OK call :Sub3
goto :eof

--------------------------------------------
Some comments about Sub1
--------------------------------------------
:Sub1
Code for Sub1
goto :eof

--------------------------------------------
Some comments about Sub2
--------------------------------------------
:Sub2
Code for Sub2
goto :eof


Hi Pegasus,

OK, I've simplified these scripts substantially, e.g.

C130_StartLocalWebServer.bat
(down to 8 lines instead of 20 because the error checking no longer
needed)
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

That's just what I wanted.

I appreciate the observations you made, i.e.:
1. Checking for existence of %2 obviates the need to check for %1
2. :EOF is built-in, obviating the need to define a symbol at
the
end
of the script

Mainly, I rely on 3 of my ~20 batch commands to start-up testing a
Ruby/Rails app. I keep those command windows open for the duration of
a testing/developing session.

Heretofore, I opened three command windows and exectuted two bath
commands in each.
With your help, I've cut that down to one command in each.

Is there a way to combine that into a single batch command, e.g.

CombineCommand.bat (pseudocode)
---------------------------------
run cmd.exe; execute batch1.bat
run cmd.exe; execute batch2.bat
run cmd.exe; execute batch3.bat

and achieve the same result I'm getting now?

Again, thanks for your help.

Regards,
Richard


Pegasus (MVP) wrote:
Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


message
Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to
work
on the Prmp project, I open several Command windows in succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step
1
and
follow that with a command step 2 with a different batch
command,
e.g.
C160_StartBreakpointer.bat, which starts a listener for any breakpoint
command executed in my Ruby/Rails application and starts an
interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs
to me
that
I can install an invocation of the followin line at the start
of
all
my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy
way
to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat
--------------------------------------------------------------------------
------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat
--------------------------------------------------------------------------
------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT


Pegasus (MVP) wrote:
"Richard" <[email protected]>
wrote
in
message
I've got a .bat file that sets a number of symbols (environment
vars)
that are useful in a number of other command windows associated
with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the
new
cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd
window
and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter
at
the
beginning of every other utility file. I tried this by
using
"cmd
/c
symbol-setter.bat" to no avail. I believe that fails
because
the
"cmd
/c" command starts a new session in which to set local
env.
vars
and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a .reg
file
appropriate to each project in which I want persistant
env.
vars,
thus
only needing to invoke that once at the inception of a project,
maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard


It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
R

Richard

Hi Pegasus,

I don't think that Set /? documents "%date:~0,3%" very well. But no
matter, because executing your examples shows that the expression is
akin to Active Server Pages or Embedded Ruby.

I fear I've taken up too much of your time. Thanks for your responses.
BTW, I'll go back and click stars for some of them.

Best wishes,
Richard
The syntax for the two sample commands is visible when you type

set /?

even though it applies to any command, e.g. echo, copy,
del etc.

Similarly the syntax for the extremely powerful "for" command
is visible when you type

for /?

Richard said:
Hi Pegasus,
echo Today is %date:~0,3%
echo The time is %time::=.%

Thanks for the additional "toys". I've recorded them in my test folder
K:\_Projects\CmdScripts\Time&Date and tested them.

I've got perhaps a dozen sites (half from Microsoft) on command
scripts, but I didn't spot any documentation on this specific syntax.
Can you point me to an on-line source?
you must make sure that neither side of the = sign is ever blank.

Duly noted. Thanks.

Regarding starting up several command windows with Start commands,
being able to set the captions in those windows is very helpful. When
I set them up manually before, I only had useful captions on windows
that were active running some command, e.g. the Ruby/Rails logger or
MySQL.

Again, many thanks for your advice.

Best wishes,
Richard

Thanks for the feedback. You'll probably find out a lot
more about batch files as you go on, especially when it
comes to the "set" and "for" commands. Try this from
a Command Prompt just for fun:

echo Today is %date:~0,3%
or
echo The time is %time::=.%

About testing equality without surrounding quotes or brackets

if %result%==OK

you must make sure that neither side of the = sign is ever blank.
If there is the slightest possibility, add some extra characters.
If you don't then the batch file will fail.

Hi Pegasus,

Great batch template! Thanks.

I tested all the features. I was surprised by a couple of things,
like the "/i" switch and the use of OK without surrounding quotes.

But the piece de resistance was the "start" command, which you
mentioned earlier but I hadn't picked up on right away. Along with the
other improvements, I got to it now and got exactly what I've got
exactly what I want:

Startup.bat
----------------
START "BAT1 Commands" Bat1.bat
START "BAT2 Commands" Bat2.bat
: etc

let's me double-click its name and get precisely the command windows I
want to support my Ruby/Rails application development efforts.

It's embarrassing to admit that I've used Windows' bat files for
decades but never noticed some of the features you've mentioned.
Again, thanks for your expert help.

Best wishes,
Richard

Pegasus (MVP) wrote:
When you ask about combining your various batch files
into the one file then you're spot on. The general idea is:
- Have all code for the one project in one single batch file.
- Make it highly structured.
- Avoid spaghetti code.
- Set global variables.
- Add lots of comments.

If you adhere to these rules then you will find that your
batch files become much more robust and are very easy
to maintain. You also skirt around the environmental variable
issue that triggered this thread.

I have seen contiguous (rather than modular) batch files that
extend over 300 lines, with numerous goto statements that
resemble the path taken by a hare in full flight. They are almost
impossible to maintain. In a structured form even a beginner
could debug and modify them.

Here is how I structure all my batch files:
=============================
@echo off
goto Start
--------------------------------------------
Program description:
Parameters:
Prerequisites:
Version:
Author:
Date:
--------------------------------------------
:Start
set SourceDir=D:\Some Folder
set TargetDir=E:\Other folder
call :Sub1
call :Sub2 %name%
if /i "%result%"==OK call :Sub3
goto :eof

--------------------------------------------
Some comments about Sub1
--------------------------------------------
:Sub1
Code for Sub1
goto :eof

--------------------------------------------
Some comments about Sub2
--------------------------------------------
:Sub2
Code for Sub2
goto :eof


message
Hi Pegasus,

OK, I've simplified these scripts substantially, e.g.

C130_StartLocalWebServer.bat
(down to 8 lines instead of 20 because the error checking no longer
needed)
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

That's just what I wanted.

I appreciate the observations you made, i.e.:
1. Checking for existence of %2 obviates the need to check for %1
2. :EOF is built-in, obviating the need to define a symbol at the
end
of the script

Mainly, I rely on 3 of my ~20 batch commands to start-up testing a
Ruby/Rails app. I keep those command windows open for the duration of
a testing/developing session.

Heretofore, I opened three command windows and exectuted two bath
commands in each.
With your help, I've cut that down to one command in each.

Is there a way to combine that into a single batch command, e.g.

CombineCommand.bat (pseudocode)
---------------------------------
run cmd.exe; execute batch1.bat
run cmd.exe; execute batch2.bat
run cmd.exe; execute batch3.bat

and achieve the same result I'm getting now?

Again, thanks for your help.

Regards,
Richard


Pegasus (MVP) wrote:
Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


message
Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to
work
on the Prmp project, I open several Command windows in
succession.
The first thing I do with each of them is drag in the name of and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command
window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are
defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound step 1
and
follow that with a command step 2 with a different batch command,
e.g.
C160_StartBreakpointer.bat, which starts a listener for any
breakpoint
command executed in my Ruby/Rails application and starts an
interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it occurs to me

that
I can install an invocation of the followin line at the start of
all
my
commands (other than C000_...) and ignore C000_... completely (and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less kludgy way
to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat


--------------------------------------------------------------------------
------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat


--------------------------------------------------------------------------
------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT


Pegasus (MVP) wrote:
in
message
I've got a .bat file that sets a number of symbols
(environment
vars)
that are useful in a number of other command windows
associated
with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into the new
cmd
window and pressing Enter
3 draging the name of one of my utility bat files in the cmd
window
and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the symbol-setter at
the
beginning of every other utility file. I tried this by using
"cmd
/c
symbol-setter.bat" to no avail. I believe that fails because
the
"cmd
/c" command starts a new session in which to set local env.
vars
and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a
.reg
file
appropriate to each project in which I want persistant env.
vars,
thus
only needing to invoke that once at the inception of a
project,
maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard


It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context of the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
P

Pegasus \(MVP\)

Hi Richard,

It's always a little disappointing when preparing a fine batch file
solution for a poster and when that person takes no further interest
other than using the ready made solution. There is much more fun
in showing a poster what can be done, i.e. responding to a lively
interest from that person.

The help text for the command you question goes like this:
=================
%PATH:~10,5%

would expand the PATH environment variable, and then use only the 5
characters that begin at the 11th (offset 10) character of the expanded
result.
=================
So how does this relate to "%date:~0,3%"? Here we go:
- %date% is an inbuilt variable. You can see its value and
format by typing this: echo %date%
- The first 3 characters of %date% are "Fri".
- The instruction "%date:~0,3%" will take the first 3 characters,
starting at the very beginning (position 0), hence it will write
"Fri" to the screen.

Depending on what programming language you have used, you
might have called this a substring, leftstring or midstring.

I suggest you plug in some other numbers, e.g.
echo "%date:~4,8%" or
echo %date:~4%

Enjoy!

Richard said:
Hi Pegasus,

I don't think that Set /? documents "%date:~0,3%" very well. But no
matter, because executing your examples shows that the expression is
akin to Active Server Pages or Embedded Ruby.

I fear I've taken up too much of your time. Thanks for your responses.
BTW, I'll go back and click stars for some of them.

Best wishes,
Richard
The syntax for the two sample commands is visible when you type

set /?

even though it applies to any command, e.g. echo, copy,
del etc.

Similarly the syntax for the extremely powerful "for" command
is visible when you type

for /?

Hi Pegasus,

echo Today is %date:~0,3%
echo The time is %time::=.%

Thanks for the additional "toys". I've recorded them in my test folder
K:\_Projects\CmdScripts\Time&Date and tested them.

I've got perhaps a dozen sites (half from Microsoft) on command
scripts, but I didn't spot any documentation on this specific syntax.
Can you point me to an on-line source?

you must make sure that neither side of the = sign is ever blank.

Duly noted. Thanks.

Regarding starting up several command windows with Start commands,
being able to set the captions in those windows is very helpful. When
I set them up manually before, I only had useful captions on windows
that were active running some command, e.g. the Ruby/Rails logger or
MySQL.

Again, many thanks for your advice.

Best wishes,
Richard


Pegasus (MVP) wrote:
Thanks for the feedback. You'll probably find out a lot
more about batch files as you go on, especially when it
comes to the "set" and "for" commands. Try this from
a Command Prompt just for fun:

echo Today is %date:~0,3%
or
echo The time is %time::=.%

About testing equality without surrounding quotes or brackets

if %result%==OK

you must make sure that neither side of the = sign is ever blank.
If there is the slightest possibility, add some extra characters.
If you don't then the batch file will fail.

Hi Pegasus,

Great batch template! Thanks.

I tested all the features. I was surprised by a couple of things,
like the "/i" switch and the use of OK without surrounding quotes.

But the piece de resistance was the "start" command, which you
mentioned earlier but I hadn't picked up on right away. Along with the
other improvements, I got to it now and got exactly what I've got
exactly what I want:

Startup.bat
----------------
START "BAT1 Commands" Bat1.bat
START "BAT2 Commands" Bat2.bat
: etc

let's me double-click its name and get precisely the command windows I
want to support my Ruby/Rails application development efforts.

It's embarrassing to admit that I've used Windows' bat files for
decades but never noticed some of the features you've mentioned.
Again, thanks for your expert help.

Best wishes,
Richard

Pegasus (MVP) wrote:
When you ask about combining your various batch files
into the one file then you're spot on. The general idea is:
- Have all code for the one project in one single batch file.
- Make it highly structured.
- Avoid spaghetti code.
- Set global variables.
- Add lots of comments.

If you adhere to these rules then you will find that your
batch files become much more robust and are very easy
to maintain. You also skirt around the environmental variable
issue that triggered this thread.

I have seen contiguous (rather than modular) batch files that
extend over 300 lines, with numerous goto statements that
resemble the path taken by a hare in full flight. They are almost
impossible to maintain. In a structured form even a beginner
could debug and modify them.

Here is how I structure all my batch files:
=============================
@echo off
goto Start
--------------------------------------------
Program description:
Parameters:
Prerequisites:
Version:
Author:
Date:
--------------------------------------------
:Start
set SourceDir=D:\Some Folder
set TargetDir=E:\Other folder
call :Sub1
call :Sub2 %name%
if /i "%result%"==OK call :Sub3
goto :eof

--------------------------------------------
Some comments about Sub1
--------------------------------------------
:Sub1
Code for Sub1
goto :eof

--------------------------------------------
Some comments about Sub2
--------------------------------------------
:Sub2
Code for Sub2
goto :eof


message
Hi Pegasus,

OK, I've simplified these scripts substantially, e.g.

C130_StartLocalWebServer.bat
(down to 8 lines instead of 20 because the error checking no longer
needed)
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

That's just what I wanted.

I appreciate the observations you made, i.e.:
1. Checking for existence of %2 obviates the need to check for %1
2. :EOF is built-in, obviating the need to define a symbol
at
the
end
of the script

Mainly, I rely on 3 of my ~20 batch commands to start-up testing a
Ruby/Rails app. I keep those command windows open for the duration of
a testing/developing session.

Heretofore, I opened three command windows and exectuted two bath
commands in each.
With your help, I've cut that down to one command in each.

Is there a way to combine that into a single batch command, e.g.

CombineCommand.bat (pseudocode)
---------------------------------
run cmd.exe; execute batch1.bat
run cmd.exe; execute batch2.bat
run cmd.exe; execute batch3.bat

and achieve the same result I'm getting now?

Again, thanks for your help.

Regards,
Richard


Pegasus (MVP) wrote:
Wow! This is one complex script!

Unfortunately it would take me far too long to analyse and
reverse-engineer it. There is certainly scopy for simplification.
Here are a few minor ones:

Of the two successive statements
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
the first one is superfluous. If %2 is blank then %1
must be blank too!

You have lots of "goto EOJ" statements. Replace them
with "goto EOF". This is an inbuilt label that does not
need to be defined.

You write
%RubyDisk%
cd %AppDir%
This should be simplyfied to
cd /d %AppDir%
(where %AppDir% now includes the drive letter).

However, this is just cosmetic stuff. I suspect that the whole
set of batch files can be condensed to perhaps twenty lines
in a single batch file, which will solve your variable problems
and will make debugging and further development much, much
easier. You would get a short, sharp and robust batch file.
To suggest how it could be done requires your functional
description of what you're attempting to do. But then you may
decide that "GO"s suggestion solves your problem, in which
case I will leave you to it.


"Richard" <[email protected]>
wrote
in
message
Hi Pegasus,

Thanks for responding.

I've got PATH= ... ; K:\_Projects\Ruby\__Links; ...

Below are four batch files. Typically, when I boot up and want to
work
on the Prmp project, I open several Command windows in
succession.
The first thing I do with each of them is drag in the name
of
and
execute a couple of batch commands, e.g.

1a. Drag the name of C000_CreateSymbols.bat into a new command
window
1b. Click the command window to give it focus
1c. Press Enter to execute the command, where upon
cwd=K:\_Projects\Ruby\_Pf\Prmp
(and symbols RubyDisk, RubyProj, CliName and AppName are
defined)
2a. Drag the name of C130_StartLocalWebServer.bat into the command
window
2b. Click the command window to give it focus
2c. Press Enter to execute the command,
whereupon the ruby starts up the WEBrick web server.

Then I open a second command window, repeat the compound
step
1
and
follow that with a command step 2 with a different batch command,
e.g.
C160_StartBreakpointer.bat, which starts a listener for any
breakpoint
command executed in my Ruby/Rails application and starts an
interactive
ruby session initialized with the application's state.

BTW, as I was documenting my environment for you, it
occurs
to me
that
I can install an invocation of the followin line at the
start
of
all
my
commands (other than C000_...) and ignore C000_...
completely
(and
eliminate all the error traps):

CreatePathAndSymbols.bat _Pf Prmp

I think that'll work. But you can probably show a less
kludgy
way
to
do the whole thing.

Best wishes,
Richard

K:\_Projects\Ruby\__Links\CreatePathAndSymbols.bat
--------------------------------------------------------------------------
------
@echo off
::: Call with arguments ClientName and ApplicationName
:: Note: Names may not include spaces nor most special characters
::
if (%1) == () goto PARM_MISSING
if (%2) == () goto PARM_MISSING
::
set RubyDisk=K:
set RubyProj=%RubyDisk%\_Projects\Ruby
::
set CliName=%1
set AppName=%2
::
set CliDir=%RubyProj%\%CliName%
set AppDir=%CliDir%\%AppName%
::
%RubyDisk%
cd %AppDir%\
::
path=%CliDir%\Cmds\;%path%
goto EOJ
::
:pARM_MISSING
echo ::
echo :: ERROR ERROR ERROR ERROR
echo :: Usage: %0 ClientName ApplicationName
echo :: ERROR ERROR ERROR ERROR
echo ::
:EOJ

K:\_Projects\Ruby\_Pf\Cmds\C000_CreateSymbols.bat
--------------------------------------------------------------------------
------
@echo off
CreatePathAndSymbols.bat _Pf Prmp
pause

C130_StartLocalWebServer.bat
---------------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT

C160_StartBreakpointer.bat
----------------------------------------
@echo off
if [%CliDir%] == [] goto ERROR
if [%AppDir%] == [] goto ERROR
if [%RubyDisk%] == [] goto ERROR
%RubyDisk%
cd %AppDir%
echo ::
echo :: Starting a Breakpointer
echo ::
@echo on
ruby script/breakpointer
@echo off
goto EXIT
:ERROR
@echo ERROR ERROR ERROR ERROR
@echo Symbol "AppDir", etc., not defined!
@echo ... run CreatePathAndSymbols.bat in your Command Window
@echo ERROR ERROR ERROR ERROR
:EXIT


Pegasus (MVP) wrote:
in
message
I've got a .bat file that sets a number of symbols
(environment
vars)
that are useful in a number of other command windows
associated
with
one of several projects. Right now, I operate by
1 opening a command window
2 draging the name of the symbol-setting bat file into
the
new
cmd
window and pressing Enter
3 draging the name of one of my utility bat files in
the
cmd
window
and
pressing Enter
4 proceeding manually entering other commands as needed.

I'd like to eliminate step 2 by invoking the
symbol-setter
at
the
beginning of every other utility file. I tried this
by
using
"cmd
/c
symbol-setter.bat" to no avail. I believe that fails because
the
"cmd
/c" command starts a new session in which to set local env.
vars
and
then ends, never communicating with the invoking session.

The best solution I can conceive of is to manually write a
.reg
file
appropriate to each project in which I want persistant env.
vars,
thus
only needing to invoke that once at the inception of a
project,
maybe
with another one to delete all such entries should the project
ultimately be destroyed.

Any comments?

Regards,
Richard


It seems you're trying to combine two different techniques
with each other: Running batch files (which is fundamentally
a Command Prompt activity) and dragging files (which is
a GUI activity). A better way would be to run a single batch
file and perhaps specify some parameters for it.

To obtain correct advice about your environmental variables
you should post the contents of your batch file. You should
also state if the variables are supposed to be valid within
the context of this batch file only, within the context
of
the
Command Prompt session it runs or within the context of
all programs, regardless of when they are launched.
 
R

Richard

Hi Pegasus,
It's always a little disappointing when preparing a fine batch file
solution for a poster and when that person takes no further interest
other than using the ready made solution. There is much more fun
in showing a poster what can be done, i.e. responding to a lively
interest from that person.

I agree fully with you. I haven't had the same experience in on-line
communication, but I'm reminded of my 13-yo grandson when he offered
this summer to spend two hours per week with me studying math if I'd
get him a cell-phone. I jumped on it and got him to learn the Binomial
Theorem, using Logarithms with interpolation, developing a recursive
formula for Pi using Archimedes method, deriving the derivative of
x^n. He's really a gifted kid, but then he switched from home
schooling to public Middle School and didn't have the will to continue.
It's sad. He didn't want to disappoint me, but I didn't want to
force him to continue. I just took back his toy. Maybe the desire for
it will inspire him again.
%PATH:~10,5%

Understood, thanks. I just didn't realized that notation applied to
strings generally.

Just to show you how I profited from your previous guidance, here's my
one-click setup for developing Ruby/Rails apps:

A000_SetupPrmpDevelopment.bat
-------------------------------------------------
Call CreatePathAndSymbols.bat _Pf Prmp
Start "Start Local WebServer" /MIN A010_StartLocalWebServer.bat
Start "Start Breakpointer" /MIN A020_StartBreakpointer.bat
Start "Clear Log Files" /MIN A030_ClearLogFiles.bat
Start "Start ERB" /MIN A040_StartERB.bat
Start "Start SearchDir" /MIN A050_StartSearchDir.bat

A010_StartLocalWebServer.bat
---------------------------------------------
@echo off
call CreatePathAndSymbols.bat _Pf Prmp
echo ::
echo :: Starting WebBrickServer
echo :: in %AppDir%
echo ::
@echo on
ruby script/server

etc. I'll probably publish this group after I've used with them for a
while, e.g. after deciding whether I want to start up the database
system every time, or maintain that as a discrete step. I like have
the separate batch files that can be invoked stand-alone, but also
being able to invoke some of them collectively with minimal redundancy.
This is really simple batch progamming, but I needed some
suggestions to "get it right" (according to my likes.)

There is one redundancy I will eliminate: the _Pf and Prmp parameters
(representing Client and Project) by invoking within the A000_Setup a
..reg file that creates persistent environment variables for RubyOnRails
Client and Project, thus allowing for the elimination of _Pf and Prmp
from the CreatePathAndSymbols invocation.

Again, I'm grateful for your help and interested in any additional
comments/suggestions/advice you may wish to share.

Best wishes,
Richard
 
P

Pegasus \(MVP\)

You're doing very nicely with your batch file commands.
I note that you're using the Start command to launch your
various batch files. This is somewhat unusual but I suppose
you have your reasons for it.

Setting environmental variables by a direct registry hack
is naughty and should be avoided. Much better to use one
of the following commands:
setx.exe (Windows Resource Kit)
setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe)

To set a variable globally ***and*** in the curren process,
use these two commands in sequence:
set name=Richard
setx name Richard -m
 
R

Richard

Hi Pegasus,
I note that you're using the Start command to launch your
various batch files.

Yes, that allows me to start a Ruby/Rails development session with a
set of minimized Command windows running helpful tools.
This is somewhat unusual but I suppose
you have your reasons for it.

Like Hamlet, there's a method to my madness :)
These batch commands start the:
- Rails breakpointer, which listens for encounters with breakpoint
stmts
- Rails "log resetter", which clears the log file
- local webserver
- Embedded Ruby application as a sandbox for testing stmts/routines

I want to be able to invoke them separately as needed, but
collectively at the start a Ruby/Rails development session. This works
great for my purposes.
setx.exe (Windows Resource Kit)
setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe)

Thanks for these. I looked them over carefully:
I note that you're using the Start command to launch your
various batch files.

Yes, that allows me to start a Ruby/Rails development session with a
set of minimized Command windows running helpful tools.
This is somewhat unusual but I suppose
you have your reasons for it.

Like Hamlet, there's a method to my madness :)
These batch commands start the:
- Rails breakpointer, which listens for encounters with breakpoint
stmts
- Rails "log resetter", which clears the log file
- local webserver
- Embedded Ruby application as a sandbox for testing stmts/routines

I want to be able to invoke them separately as needed, but
collectively at the start a Ruby/Rails development session. This works
great for my purposes.
setx.exe (Windows Resource Kit)
setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe)

Thanks for these. I looked them over carefully:

-- The -u switch causes both of them to store the name=>value in the
HKEY_CURRENT_USER\Environment key. From the Control Panel perspective,
adds them to the User env. variables.

-- The -m switch targets the
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session
Manager\Environment key and the System env. variables.

-- If invoked from a Command Window, both commands (regardless of the
switch provided) require invocation of a new command window before the
their effects will be felt.

-- Bottom line for me: it's great to have these commands available.
The -m and -u switches yield the same effect in my humble lab: I only
run under a single user account. I speculate that the setenv.exe pgm
was written before Microsoft made setx available. I didn't notice any
additional functionality in serenv.exe, though I didn't check that
carefully.
To set a variable globally ***and*** in the curren process,
use these two commands in sequence:
set name=Richard
setx name Richard -m

In the case of execution from within a Command Window, that sequence
doesn't appear to me to make the value of "name" available in the
current process, since there's now way to get the Command window to
refresh it's cached copy of the Registry. Do you agree?

Again, thanks for the guidance. It saved me a lot of time.

Best wishes,
Richard
 
R

Richard

Hi Pegasus,
I note that you're using the Start command to launch your
various batch files.

Yes, you mentioned it in one of your early replies. It allows me to
start a Ruby/Rails development session with a set of minimized Command
windows running helpful tools.
This is somewhat unusual but I suppose
you have your reasons for it.

Like Hamlet, there's a method to my madness :)
These batch commands start the:
- Rails breakpointer, which listens for encounters with breakpoint
stmts
- Rails "log resetter", which clears the log file
- local webserver
- Embedded Ruby application as a sandbox for testing stmts/routines

I want to be able to invoke them separately as needed, but
collectively at the start a Ruby/Rails development session. This works
great for my purposes.
setx.exe (Windows Resource Kit)
setenv.exe (ftp://barnyard.syr.edu/pub/vefatica/setenv.exe)

Thanks for these. I looked them over carefully. Following is my take
on them:

-- The -u switch causes both of them to store the name=>value in the
HKEY_CURRENT_USER\Environment key. From the Control Panel perspective,
adds them to the User env. variables.

-- The -m switch targets the
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session
Manager\Environment key and the System env. variables.

-- If invoked from a Command Window, both commands (regardless of the
switch provided) require invocation of a new command window before the
their effects will be felt.

-- Bottom line for me: it's great to have these commands available.
The -m and -u switches yield the same effect in my humble lab: I only
run under a single user account. I speculate that the setenv.exe pgm
was written before Microsoft made setx available. I didn't notice any
additional functionality in serenv.exe, though I didn't check that
carefully.
To set a variable globally ***and*** in the curren process,
use these two commands in sequence:
set name=Richard
setx name Richard -m

In the case of execution from within a Command Window, that sequence
doesn't appear to me to make the value of "name" available in the
current process, since there's now way to get the Command window to
refresh it's cached copy of the Registry. Do you agree?

Again, thanks for the guidance. It saved me a lot of time.

Best wishes,
Richard
 
P

Pegasus \(MVP\)

In the case of execution from within a Command Window, that sequence
doesn't appear to me to make the value of "name" available in the
current process, since there's now way to get the Command window to
refresh it's cached copy of the Registry. Do you agree?

The command
set name=Richard
will set %name% in the environment memory space of your
current process.

The command
setx name Richard -m
will set %name% in the registry. This variable is now accessible
to all ***newly*** launched processes but it will not affect any
***pre-existing*** processes.
 
R

Richard

Hi Pegasus,
The command
set name=Richard
will set %name% in the environment memory space of your
current process.

My apology. I misread your original message thinking that you were
using a pair of setx statements with and without the -m switch.

I've got all my batch stuff working perfectly now for all my Ruby/Rails
application development efforts. I've got top level commands for all
my RoR projects that set two environment variables in the Registry:
Client and Application. I only work on one of them at a time and
switching between them takes only one double-click. The suite of
standard helper applications (relying only on %Client% and
%Application%) can then be invoked with only one more double-click.
Life's good.

Best wishes,
Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top