Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to index page
Thread view  Board view
CluelessInSeattl(R)

Seattle, USA,
08.03.2013, 16:45
 

MS-DOS command to show logged drive and directory? (Users)

Is there an MS-DOS command that will show me the current drive and directory path I'm logged onto?

I'd like to insert that into a batch file that will show me where I am and give me a choice of proceeding or exiting and logging onto the correct drive and directory.

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

bretjohn(R)

Homepage E-mail

Rio Rancho, NM,
08.03.2013, 16:50

@ CluelessInSeattl
 

MS-DOS command to show logged drive and directory?

I'm not sure exactly what you mean by "logging", but isn't that what a "PROMPT $P$G" does?

CluelessInSeattl(R)

Seattle, USA,
08.03.2013, 19:58

@ bretjohn
 

MS-DOS command to show logged drive and directory?

> I'm not sure exactly what you mean by "logging",

Hi bretjohn,

Here's a link to an explanation of what I had in mind:

Logging on to a drive

Maybe they don't use that term anymore these days. That's what we had to do each time we put a disk in our CP/M computers.

> but isn't that what a
> "PROMPT $P$G" does?

I tried that in a short batch file called WHEREAMI.BAT

@echo off
echo Where am I?
PROMPT $P$G
echo Did it work?


What I had hoped to see on the screen was:

Where am I?
C:\BAT
Did it work?


But instead it just showed:

Where am I?
Did it work?

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

rr(R)

Homepage E-mail

Berlin, Germany,
08.03.2013, 20:32

@ CluelessInSeattl
 

MS-DOS command to show logged drive and directory?

> Is there an MS-DOS command that will show me the current drive and
> directory path I'm logged onto?

Just: cd

CluelessInSeattl(R)

Seattle, USA,
08.03.2013, 22:51

@ rr
 

MS-DOS command to show logged drive and directory?

> Just: cd

Thanks, rr!

That did the trick!

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

CluelessInSeattl(R)

Seattle, USA,
10.03.2013, 20:02

@ CluelessInSeattl
 

How to have MS-DOS "remember" logged drive and directory?

OK, now I want to make a batch file that remembers the current logged drive and directory (What do you call that anyway. It's not the "path" is it?) and then re-log me back onto that drive and directory later on.

It was easy for me to simply redirect the output of the CD command to a textfile named U_R_HERE.TXT like this:

CD>e:\temp\U_R_HERE.TXT

But I'm having trouble figuring out how to tell MS-DOS 6.21 to log back into that drive and directory later on.

I tried this, but it didn't work:

CD <e:\temp\U_R_HERE.TXT

Any ideas?

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

CluelessInSeattl(R)

Seattle, USA,
11.03.2013, 00:31

@ CluelessInSeattl
 

PUSHD and POPD in MS-DOS 6.21?

A BBS friend suggested I try PUSHD and POPD but I can't find them in my MS-DOS 6.21 manual.

I'm wondering if DOS 6.21 might have equivalent commands, or if there's a way to get MS-DOS 6.21 accomplish the same thing using existing commands.

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

glennmcc(R)

Homepage E-mail

North Jackson, Ohio (USA),
11.03.2013, 00:54

@ CluelessInSeattl
 

PUSHD and POPD in MS-DOS 6.21?

> A BBS friend suggested I try PUSHD and POPD but I can't find them in my
> MS-DOS 6.21 manual.
>
> I'm wondering if DOS 6.21 might have equivalent commands, or if there's a
> way to get MS-DOS 6.21 accomplish the same thing using existing commands.

http://ftp.sunet.se/pub/simtelnet/msdos/dirutl/pushpop.zip

---
--
http://glennmcc.org/

CluelessInSeattl(R)

Seattle, USA,
11.03.2013, 02:06

@ glennmcc
 

PUSHD and POPD in MS-DOS 6.21?

> http://ftp.sunet.se/pub/simtelnet/msdos/dirutl/pushpop.zip

Thanks, glennmcc!

I'm reading the documentation that comes with pushpop.zip and have some questions about how to use the .exe files in my batch file.

Have you used these programs?

Would you be up for fielding some questions from me?

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

glennmcc(R)

Homepage E-mail

North Jackson, Ohio (USA),
11.03.2013, 03:39

@ CluelessInSeattl
 

PUSHD and POPD in MS-DOS 6.21?

> > http://ftp.sunet.se/pub/simtelnet/msdos/dirutl/pushpop.zip
>
> Thanks, glennmcc!
>
> I'm reading the documentation that comes with pushpop.zip and have some
> questions about how to use the .exe files in my batch file.
>
> Have you used these programs?
>
> Would you be up for fielding some questions from me?

Sorry, never used 'em, don't know anything about 'em,
just knew how to use Google to find 'em.

---
--
http://glennmcc.org/

marcov(R)

11.03.2013, 20:28

@ glennmcc
 

PUSHD and POPD in MS-DOS 6.21?

> > A BBS friend suggested I try PUSHD and POPD but I can't find them in my
> > MS-DOS 6.21 manual.
> >
> > I'm wondering if DOS 6.21 might have equivalent commands, or if there's
> a
> > way to get MS-DOS 6.21 accomplish the same thing using existing
> commands.
>
> http://ftp.sunet.se/pub/simtelnet/msdos/dirutl/pushpop.zip

Or 4dos/4nt. 4dos handles nested cases too.

rr(R)

Homepage E-mail

Berlin, Germany,
11.03.2013, 21:01

@ CluelessInSeattl
 

PUSHD and POPD in MS-DOS 6.21?

> A BBS friend suggested I try PUSHD and POPD but I can't find them in my
> MS-DOS 6.21 manual.

These were introduced in Windows' cmd.exe.

> I'm wondering if DOS 6.21 might have equivalent commands, or if there's a
> way to get MS-DOS 6.21 accomplish the same thing using existing commands.

(Untested) from batfaq23.zip:

 9.          JUMP BACK TO PRIOR DRIVE / DIRECTORY
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Q: When I run a program or command how can I get back to the
     directory that was current prior to command execution ?
  A: Several solutions are available as small utilities but
     below is a pure DOS solution.(using environment variables)
     (4DOS has built in variables to deal with this situation)

     ::Set Envars to current drive & current directory
     @echo @prompt SET OLDRV$Q$N$_SET OLDIR$Q$P >C:\TEMP$TMP.BAT
     @%COMSPEC% /e:1024 /c C:\TEMP$TMP.BAT >C:\TEMP$$MP.BAT
     @call C:\TEMP$$MP.BAT >nul
     @del C:\TEMP$?MP.BAT

     Once this BATch has been CALL'd or run:
     %OLDRV% will be evaluated to be the drive when BAT was run
     and %OLDIR% will be evaluated to be the prior directory.

CluelessInSeattl(R)

Seattle, USA,
11.03.2013, 23:34

@ rr
 

PUSHD and POPD in MS-DOS 6.21?

Thanks a million, rr!

It looks like someone has already written exactly what I need.

Now if I can only understand what the code means and how to use it.

I'm going to have to study it to see if I can figure out how it works.

So you've given me my homework assignment for tonight.

Thanks, teacher! ;-)

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

CluelessInSeattl(R)

Seattle, USA,
12.03.2013, 00:24

@ CluelessInSeattl
 

PUSHD and POPD in MS-DOS 6.21?

OK, I took that batch file for a spin.

And it seemed like it was trying to do its job, (even though I don't have a clue how it actually works), but then I got this error message:

"Out of environment space"

I tried looking in my MS-DOS 5.0 manual to figure out how to increase the environment space. But I swear, that book seems to be written in a foreign language.

From want I gather I'm going to have to modify my CONFIG.SYS file and change the COMMAND /e: setting. Is that right?

I just looked at my CONFIG.SYS and found this line in it:

shell=c:\command.com /e:1024 /p

Could you suggest how I should modify it?

If it's any help, the batch file I just tried running choked up on a directory path that was something like 40 characters long, and only had room for the first three or four characters.

I often nest directories down three, four or more levels, so should probably make enough room for at least a five level directory path.

It's not clear from reading the manual if I can issue the COMMAND command from the command prompt, or if it can only be issued from the CONFIG.SYS file.

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

glennmcc(R)

Homepage E-mail

North Jackson, Ohio (USA),
12.03.2013, 02:07

@ CluelessInSeattl
 

PUSHD and POPD in MS-DOS 6.21?

>
> "Out of environment space"
>

Increase the ENV space from 1kb to 2kb like so....

shell=c:\command.com /e:2048 /p

---
--
http://glennmcc.org/

ron(R)

Homepage E-mail

Australia,
11.03.2013, 05:22

@ CluelessInSeattl
 

How to have MS-DOS "remember" logged drive and directory?

> It was easy for me to simply redirect the output of the CD command to a
> textfile named U_R_HERE.TXT like this:
>
> CD>e:\temp\U_R_HERE.TXT
>
> But I'm having trouble figuring out how to tell MS-DOS 6.21 to log back
> into that drive and directory later on.
>
> Any ideas?

It should be easy enough to write a little utility that can do that,
e.g. "save current" and "return".

You would just have to remember how to "save" and "return".

---
AUSREG Consultancy http://www.ausreg.com
Tadpole Tunes http://www.tadpoletunes.com
Sna Keo Il http://www.tadpoletunes.com/sna_keo_il/

georgpotthast(R)

Homepage

Germany,
11.03.2013, 08:00

@ ron
 

How to have MS-DOS "remember" logged drive and directory?

You could write the current drive into an environment variable with the SET command and then read that later on in the batch file with e.g. %my_drive%

Georg

CluelessInSeattl(R)

Seattle, USA,
11.03.2013, 15:39

@ georgpotthast
 

How to have MS-DOS "remember" logged drive and directory?

> You could write the current drive into an environment variable with the SET
> command and then read that later on in the batch file with e.g. %my_drive%

Thanks Georg,

That sounds like a simple and straightforward solution to my problem.

But I have to confess that I don't have a clue how to implement it.

I've been trying over and over, and just keep getting error messages. So I'd be grateful for some hints about how to proceed.

My problem has two parts:

1. How to record the path to the current drive and directory,

2. And then how to log back onto that drive and directory later.

I thought I had already figured out how to solve part 1 by writing the output of the CD command to a text file.

So from the MS-DOS 6.21 command prompt I tried this to turn that text into a variable:

SET DIRPATH <e:\temp\dirpath.txt

That seemed to work; as I didn't receive an error message.

But I don't know how to check to see what was actually saved into the %DIRPATH% variable. (It would be helpful to me if I could look at it to make sure that the correct drive and directory path was actually saved to that variable. Could you tell me how to see what that variable now represents?).

But then, when I typed this at the command prompt:

CD %DIRPATH%

I got an "Invalid directory" error message.

So, as you can see, I'm stumbling around in the dark here. Any light you can shed on my path will be gratefully appreciated.

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

bretjohn(R)

Homepage E-mail

Rio Rancho, NM,
12.03.2013, 00:39

@ CluelessInSeattl
 

How to have MS-DOS "remember" logged drive and directory?

What exactly are you trying to accomplish?

If you are wanting to write a batch file to do something, and want to make sure that after the batch file is done you are in the same drive and directory where you started, things actually get pretty complicated and you will probably want to use programs like PUSHD and POPD. I suspect that's what you are trying to do, and if so, I can explain a little further as to why simply setting an environment variable is insufficient.

If you're just trying to do things from the command line, and not with a batch file, an environment variable /might/ work, but even in that situation PUSHD and POPD are a better alternative.

CluelessInSeattl(R)

Seattle, USA,
12.03.2013, 00:59

@ bretjohn
 

How to have MS-DOS "remember" logged drive and directory?

> What exactly are you trying to accomplish?

I want to make a batch file that "remembers" the current logged drive and directory and then later can "recall" and re-log me back onto that drive and directory after some operations have changed the logged drive and directory.

> If you are wanting to write a batch file to do something, and want to make
> sure that after the batch file is done you are in the same drive and
> directory where you started, things actually get pretty complicated and you
> will probably want to use programs like PUSHD and POPD.

If you've used these in DOS 6.21, then I'd be grateful if you could walk me through how to write them into a batch file.

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

nidud(R)

E-mail

Norway,
12.03.2013, 12:45

@ CluelessInSeattl
 

How to have MS-DOS "remember" logged drive and directory?

There is also a program (source code) in this tread called CDPUSH:
http://www.bttr-software.de/forum/mix_entry.php?id=10195#p10422

This saves the current directory to %TEMP%\cdpop.bat

To use this in a batch file:

C:\BIN\cdpush

...

%TEMP%\cdpop

ron(R)

Homepage E-mail

Australia,
12.03.2013, 13:02

@ CluelessInSeattl
 

How to have MS-DOS "remember" logged drive and directory?

> > What exactly are you trying to accomplish?
>
> I want to make a batch file that "remembers" the current logged drive and
> directory and then later can "recall" and re-log me back onto that drive
> and directory after some operations have changed the logged drive and
> directory.

Maybe this will suit your need.
http://www.ausreg.com/files/gobak.exe

Place it somewhere IN YOUR PATH.

To save the current drive and directory, at the CLI type: gobak s
To return to the previously saved directory, type: gobak r
For help, type: gobak ?

The "saved" drive:\directory is written to the file: c:\gobak.dat.
This file is stored intact until you over-write it by typing "gobak s" again.

It works just fine on my MSDOS 6.20.
I hope it does what you want it to do.

---
AUSREG Consultancy http://www.ausreg.com
Tadpole Tunes http://www.tadpoletunes.com
Sna Keo Il http://www.tadpoletunes.com/sna_keo_il/

CluelessInSeattl(R)

Seattle, USA,
12.03.2013, 18:42

@ ron
 

How to have MS-DOS "remember" logged drive and directory?

> Maybe this will suit your need.
> http://www.ausreg.com/files/gobak.exe

Hey, ron!

That seems to be just what the doctor ordered.

I just tried it out in a test.bat file, and it worked exactly as described.

Thanks a million!

I'd like to thank all the others; bretjohn, rr, glennmcc, marcov, georgpotthast, nidud, (did I miss anyone?); who offered guidance, ideas, and suggestions. As many of you already know, I'm an old guy disabled by worsening chronic illnesses, so I can only spend a few minutes a day at my computer. My vision is deteriorating, as are my memory and cognitive skills. So I need all the help I can get and am deeply grateful to you guys for being so patient with me.

I get a great deal of satisfaction out of trying to get my old MS-DOS 6.21 system up and running again, like it did back in the day when I could spend entire days, day after day, writing code and tweaking the system. I believe that my working on this project may help slow down my mental decline. And even if it doesn't. It's a hell of a lot of fun! :-)

I'd like to follow-up on some of the other suggestions you guys have offered as ways to solve the problem I posed to you at the outset of this thread. I'm especially interested in learning more about environmental variables and reconfiguring the environment space.

But that's all for now. I need to take a rest, and then get on with the mundane tasks of daily living that now consume nearly all my time and energy these days.

Thanks again! You guys are terrific!

---
Will in Seattle
a.k.a. "Clueless"
Running MS-DOS 6.21

RayeR(R)

Homepage

CZ,
13.03.2013, 01:26

@ CluelessInSeattl
 

How to have MS-DOS "remember" logged drive and directory?

Sorry I don't have enough time and power to read whole thread but I would like to mention very usefull utility INDIR: http://www.softpedia.com/get/System/Benchmarks/INDIR.shtml (don't care about description it's for DOS)
It will allow you to execute another program from specified directory without a need to change directory to program dir and back - you don't need do pushd/popd. I use it in many batch files.

---
DOS gives me freedom to unlimited HW access.

bretjohn(R)

Homepage E-mail

Rio Rancho, NM,
13.03.2013, 04:12

@ RayeR
 

How to have MS-DOS "remember" logged drive and directory?

Just tired INDIR, seems to work well. I've never seen it before. It does use a lot of memory, though (almost 25k).

bretjohn(R)

Homepage E-mail

Rio Rancho, NM,
12.03.2013, 17:03

@ CluelessInSeattl
 

How to have MS-DOS "remember" logged drive and directory?

> I want to make a batch file that "remembers" the current logged drive and
> directory and then later can "recall" and re-log me back onto that drive
> and directory after some operations have changed the logged drive and
> directory.

Here's the hopefully short and understandable explanation.

In DOS, changing drives and changing directories are actually two separate functions. This is actually a pretty critical concept. Look at the following sequence (this assumes a PROMPT $P$G has been issued):

S:\> C:
C:\> CD S:\UTIL
C:\> S:
S:\UTIL>

The CD command on the second line changed the working (logged?) directory on S:, but didn't actually "log" onto the S: drive -- it stayed on C:. Changing the working drive to S: is a different command. This is true both at the command line and when programs (like PUSHD and POPD) "ask" DOS to do it for them.

Now let's do a sequence using PUSHD and POPD, which will "remember" the current working drive and directory and allow you to restore it:

S:\> C:
C:\> PUSHD S:\UTIL
S:\UTIL> POPD
C:\> S:
S:\UTIL>

PUSHD saved the current working drive and directory, and then changed both the working drive and directory. POPD was then able to restore things back to the original working drive and directory. Unfortunately, this sequence also changed the working directory on S:, and never restored it back to where it was when it started.

The point of all this is to point out that you need to use PUSHD/POPD more than once if you want to really restore everything back to the way it was when you started. The goal of your batch files should be to restore _everything_ back to the way it was when you started. that is, not just the working drive and directory, but also the working directories on all drives that you may have accessed along the way.

If you try to do something like this with environment variables, you need at least two of them, not just one. The only time you could ever get by with just one is if you only had one drive (say, C:) and never used floppies or USB drives or CD-ROM's or RAM disks or network drives or ... In the unlikely event that you did only have one drive, a single environment variable wouldn't allow you to nest (CALL) batch files from each other.

You need to create a "stack" of saved drives and directories, and need to keep the drives and directories separate from each other. I set up most of my batch files similar to this:

@ECHO OFF
PUSHD C: <- Save current drive & directory, switch to C:
PUSHD \Path2Use <- Save current directory on C:, switch to directory I need
Program <- Run Program from C:\Path2Use
POPD <- Restore original working directory on C:
POPD <- Restore original working drive and directory

A few notes about the PUSHD/POPD in the link above. PUSHD creates files in the directory where the %TEMP% (or %TMP%) environment variable points. If %TEMP% is not pointed at a RAM drive (which gets erased automatically when you reboot), you can end up with a bunch of useless files created by PUSHD if you have problems with batch files or programs that cause reboots. If %TEMP% is not on a RAM drive, you may want to make sure to delete any files created by PUSHD from the previous session when you reboot (you should add something to your AUTOEXEC.BAT to handle this).

PUSHD/POPD also don't work natively with long file names, though there are ways to get around that if you really want to.

For many years I used some old PC Magazine utilities called PUSHDIR and POPDIR to do this. PUSHDIR is actually a TSR, so it stored things in memory instead of the hard drive. The disadvantage, of course, is that it used memory.

j_hoff(R)

13.03.2013, 21:44

@ CluelessInSeattl
 

How to have MS-DOS "remember" logged drive and directory?

Well, this:

> CD>e:\temp\dirpath.tx
> SET DIRPATH <e:\temp\dirpath.txt

doesn't work. But that way:

CD | PIPESET DIRPATH

it should do the trick and you could return to your original directory just the way you wanted to do it, simply by:

> CD %DIRPATH%

Back to index page
Thread view  Board view
15196 Postings in 1365 Threads, 250 registered users, 13 users online (0 registered, 13 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum