[comp.sys.ibm.pc] Strange DOS behavior

akk2@ur-tut.UUCP (Atul Kacker) (05/08/87)

I just tried the following on my PC running DOS 3.2.

Inserted a floppy in drive A, which had a write protect tab
on it. Changed the default drive to A> from C>. Then
typed     

A>  TYPE filename.ext | MORE

and I got an error message  

Write protect error writing drive A:

A)bort, R)etry, I)gnore ?

What's going on ?

I am only trying to read from the disk. Am I missing something here ?


-- 
-----------------------
Atul Kacker
UUCP: ...seismo!rochester!ur-tut!akk2e

apn@nonvon.UUCP (root) (05/09/87)

in article <1293@ur-tut.UUCP>, akk2@ur-tut.UUCP (Atul Kacker) says:
> I just tried the following on my PC running DOS 3.2.
> Inserted a floppy in drive A, which had a write protect tab
> on it. Changed the default drive to A> from C>. Then
> typed     
> 
> A>  TYPE filename.ext | MORE
> and I got an error message  
> Write protect error writing drive A:
> A)bort, R)etry, I)gnore ?
> What's going on ?
> I am only trying to read from the disk. Am I missing something here ?
> 
> -- 
> -----------------------
> Atul Kacker
> UUCP: ...seismo!rochester!ur-tut!akk2

	well... yes.   Our all so famous DOS uses disk space for
temporary storage for pipes.
	If, however you make C: your default when you type in this
command then it will put the pipe files on C:

say 'C> type a:filename.ext | more'

leonard@percival.UUCP (Leonard Erickson) (05/09/87)

Whenever you use the | DOS uses a temporary file for the output
of the first program. It then uses said file for the input
of the second program. After the second program is finished
DOS kills the file. 

Thus the write protect error. You can also crash a pipe if there
isn't enough space left on the disk. Pipe file names are *weird*.

-- 
Leonard Erickson		...!tektronix!reed!percival!leonard
CIS: [70465,203]		...!tektronix!reed!percival!!bucket!leonard
"I used to be a hacker. Now I'm a 'microcomputer specialist'.
You know... I'd rather be a hacker."

bobmon@iuvax.UUCP (Che' Flamingo) (05/09/87)

akk2@ur-tut.UUCP (Atul Kacker) writes:
>I just tried the following on my PC running DOS 3.2.
>
>Inserted a floppy in drive A, which had a write protect tab
>on it. Changed the default drive to A> from C>. Then
>typed     
>
>A>  TYPE filename.ext | MORE
>
>and I got an error message  
>
>Write protect error writing drive A:
>	[...]

MSDOS isn't Unix -- the pipe merely creates a temporary diskfile for the output
of the first program, collects ALL output there, then runs the second program
using the temporary file for input.  (Unix uses a memory buffer, and blocks/
unblocks each program as the buffer fills and empties.)  Thus an MSDOS pipe will
fail if the temporary file can't be written, or if you run out of diskspace.

My v3.1 documentation claims that the temp. files go on the current directory of
the default disk.  Either you aren't using Zenith's MSDOSv3.1, or the doc. is
wrong (did you boot from the A drive?), or there's an explanation I haven't
thought of.

perkins@bnrmtv.UUCP (Henry Perkins) (05/10/87)

In article <1293@ur-tut.UUCP>, akk2@ur-tut.UUCP (Atul Kacker) writes:
> Inserted a floppy in drive A, which had a write protect tab
> on it. Changed the default drive to A> from C>. Then typed
> 
> A>  TYPE filename.ext | MORE
> 
> and I got an error message:   Write protect error writing drive A:
> I am only trying to read from the disk. Am I missing something here ?

MS-DOS doesn't have RAM pipes; it uses temporary files on the
default drive.

Incidentally, you could have probably done what you wanted to
accomplish with

   A>  MORE < filename.ext

which would have avoided the temporary pipe file.  The only
difference between TYPE and just sending a file to standard
output is in handling of a few special characters (like
expanding tabs to spaces).  If you're using an ANSI device
driver (like the standard ANSI.SYS, these issues are taken
care of.  Besides, avoiding TYPE makes the command faster.


-- 
{hplabs,amdahl,3comvax}!bnrmtv!perkins        --Henry Perkins

It is better never to have been born.  But who among us has such luck?
One in a million, perhaps.

cavender@drivax.UUCP (Steve Cavender) (05/10/87)

In article <1293@ur-tut.UUCP> akk2@ur-tut.UUCP (Atul Kacker) writes:
>I just tried the following on my PC running DOS 3.2.
...
>A>  TYPE filename.ext | MORE
>
>and I got an error message  
>
>Write protect error writing drive A:
...
>I am only trying to read from the disk. Am I missing something here ?

>Atul Kacker

Yes.  The something missing is concurrency of processes.  Since 'TYPE' and
'MORE' run sequentially, pipes in PC- or MS- DOS are implemented via files
on disk.  The command interpreter redirects stdout of 'TYPE' to a temporary
file on drive A, which gets you the write protect error.  If drive A had not
been write protected, 'TYPE' would have run to completion, then 'MORE' would
have been run with stdin redirected to that same file.

'MORE' can still be used on a write protected drive (at least for what you were
trying to accomplish above) with the following command:

	A>MORE <filename.ext

-- 
Steve Cavender     Digital Research |(My opinions.  You can't have them.)
USENET:    cavender@drivax.UUCP     |"The Zaphod Beeblebrox?"
Telex:     9102406616               |"No, just a Zaphod Beeblebrox, didn't you
EasyLink:  62211010                 |hear I come in six packs?"

cforeman@dasys1.UUCP (05/11/87)

In article <1293@ur-tut.UUCP>, akk2@ur-tut.UUCP (Atul Kacker) writes:
> 
> A>  TYPE filename.ext | MORE
> and I got an error message  
> Write protect error writing drive A:
> I am only trying to read from the disk. Am I missing something here ?
> -----------------------
> Atul Kacker
> UUCP: ...seismo!rochester!ur-tut!akk2

What you are missing is the way MS/PC-DOS handles pipes. When you pipe
the output of TYPE into MORE what actually happens is that temporary
files are created by the operating system which contain the output from
TYPE. When the TYPE  command has completed, the temporary files are
used to feed MORE which produces your output. This is necessary because
MS/PC-DOS has no multitasking capability. If it did, MORE could run
concurrently with TYPE and the output could be fed directly to MORE without
ever writing to the disk. Unfortunately, this feature does not exist
and the output has to be kept somewhere - on the disk.

-Charles


-- 
Charles Foreman                  {allegra,philabs,cmcl2}!phri\
Datamerica Systems               {bellcore,harpo,cmcl2}!cucard!dasys1!cforeman
New York, NY, USA                                {philabs}!tg/
		'87 Mets - Let's Do It Again!

platt@emory.UUCP (Dan Platt) (05/11/87)

In article <1293@ur-tut.UUCP> akk2@ur-tut.UUCP writes:
>I just tried
	(on dos3.2 using a pipe on a write protected disk).
>...Changed the default drive to A> from C>. Then
>              A>  TYPE filename.ext | MORE
>and I got an error message  
>Write protect error writing drive A:
>A)bort, R)etry, I)gnore ?

Yes, you are missing something: the pipes construct temorary files which
are then sent to "more" and other filters.  These temporary files appear in
the default drive which in this case was write protected.

ger@qtecmuc.UUCP (05/11/87)

	Inserted a floppy in drive A, which had a write protect tab
	on it. Changed the default drive to A> from C>. Then
	typed     
	A>  TYPE filename.ext | MORE
	and I got an error message  
	Write protect error writing drive A:

Unfortunately Pipes (prog1 | prog2) are handled as:
prog1 >tempfile
prog2 <tempfile
im MS-DOS,
since there is no multitasking mechanism there.
The tempfile is created in the root of the current (I think) drive.
Thats the reason for the 'write protect'-error.

heff@bsdpkh.ATT.COM (Paul K Heffner) (05/11/87)

in article <1293@ur-tut.UUCP>, akk2@ur-tut.UUCP says:
> Keywords: DOS
> 
> Inserted a floppy in drive A, which had a write protect tab
> on it. Changed the default drive to A> from C>. Then
> typed     
> A>  TYPE filename.ext | MORE
> and I got an error message  
> Write protect error writing drive A:
> What's going on ?
> Atul Kacker

Under Toynix (MS-DOS) pipes are implemented as temporary files which are
written to the root directory of your currently active disk. They're
usually named something like "%PIPE1.$$$". Try the command line:
dir|sort|more
and you should see two of 'em at the head of the list. The write error
occurred when the system attempted to save your pipe. It probably
won't happen if you issue "dir a:" while logged into "c:" (assuming
c: isn't r/o itself)

Heff

cramer@kontron.UUCP (05/11/87)

> I just tried the following on my PC running DOS 3.2.
> 
> Inserted a floppy in drive A, which had a write protect tab
> on it. Changed the default drive to A> from C>. Then
> typed     
> 
> A>  TYPE filename.ext | MORE
> 
> and I got an error message  
> 
> Write protect error writing drive A:
> 
> A)bort, R)etry, I)gnore ?
> 
> What's going on ?
> 
> I am only trying to read from the disk. Am I missing something here ?
> 
> Atul Kacker

Unlike UNIX, PC-DOS doesn't have true interprocess pipes.  The | simulates
pipes by writing stdout to a temporary disk file on the current disk and
directory, and telling the next program in the line to read stdin from that
temporary file.

Clayton E. Cramer

ephram@violet.berkeley.edu (05/13/87)

 Is whole discussion raises an interesting question.  Is there a way to patch
DOS to create pipe files on the c: drive?  How about a RAM disk ?  That
would speed up things a little bit .


ephram@violet.berkeley.edu

doug@edge.UUCP (05/14/87)

> Inserted a floppy in drive A, which had a write protect tab
> on it. Changed the default drive to A> from C>. Then
> typed     
> 
> A>  TYPE filename.ext | MORE
> 
> and I got an error message  
> 
> Write protect error writing drive A:

In PC-DOS, pipes are implemented by writing the output of the first
program into a temporary file on the current drive, and then giving
that file to the next program as input.

This is obviously necessary, because PC-DOS doesn't support multi-tasking
and therefore can't have both programs in memory at the same time.

What would have worked is either
   A>  MORE <filename.ext
or
   C>  TYPE A:filename.ext | MORE   (note current drive is still C:)

Personally, I prefer the former; why run two programs when one will do?
Besides, then you don't need enough free space to make a duplicate of the
file.
-- 
Doug Pardee -- Edge Computer Corp., Scottsdale, AZ -- ...!ihnp4!mot!edge!doug

madd@bucsb.bu.edu.UUCP (05/17/87)

In article <3543@jade.BERKELEY.EDU> ephram@violet.berkeley.edu () writes:
> Is whole discussion raises an interesting question.  Is there a way to patch
>DOS to create pipe files on the c: drive?  How about a RAM disk ?  That
>would speed up things a little bit .

I'm pretty sure that msdos puts pipe files on the current working
drive, although I could be wrong and it puts them on the system boot
disk.  It's for sure that it puts them on my c: drive 
(harddisk) using msdos v3.1, 3.2, 3.21, and 3.3 (yes, I've tried 'em
all).  My machine is a few hundred miles away right now or I'd
check...

After thinking about it for a minute, I'd be amazed if msdos didn't
just put it in the default drive.  If it didn't, then your
write-protected dos disk would cause pipe failures all the time.  Of
course, not many people I know has write-protected their disks, but
one guy I know has done it and he seems to have no problems with
pipes (dos disk in A: and some other disk in B:, obviously, or he
would have had problems!).  Besides, if it did not operate this way,
they probably would have made some kind of a PIPESPEC entry in
CONFIG.SYS.  They did this for COMMAND.COM so that the system ran
cleaner when bringing it up on hard disks and the like.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
          Jim Frost * The Madd Hacker | UUCP: ..!harvard!bu-cs!bucsb!madd
  H H                                 | ARPA:           madd@bucsb.bu.edu
H-C-C-OH <- heehee          +---------+----------------------------------
  H H                       | "We are strangers in a world we never made"