Re: Persisting env vars in cmd windows
- From: "Richard" <RichardDummyMailbox58407@xxxxxxxxxxxxxxxxxxx>
- Date: 5 Nov 2006 21:11:01 -0800
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" <RichardDummyMailbox58407@xxxxxxxxxxxxxxxxxxx> wrote in message
news:1162763712.640301.320540@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.
.
- Follow-Ups:
- Re: Persisting env vars in cmd windows
- From: Pegasus \(MVP\)
- Re: Persisting env vars in cmd windows
- References:
- Persisting env vars in cmd windows
- From: Richard
- Re: Persisting env vars in cmd windows
- From: Pegasus \(MVP\)
- Persisting env vars in cmd windows
- Prev by Date: Re: 2000 admin password
- Next by Date: Re: Persisting env vars in cmd windows
- Previous by thread: Re: Persisting env vars in cmd windows
- Next by thread: Re: Persisting env vars in cmd windows
- Index(es):
Relevant Pages
|
|