[alt.unix.wizards] rcp behavior

scott@nbc1.ge.com (Scott Barman) (11/06/90)

[Since net.non-rational-thinking has really made a mess of things (this
is what I get for being too busy to notice), I am not sure where to post
this now!]

I wrote and maintaining a program that has to run on both Suns and
MicroVaxes (not my choice so save your flames).  To make sure sources
stay the same on all machines I am using my Makefile to rcp the changed
sources to the other machines.  There are NFS mounts to all these
machines but considering the MicroVaxes are running a brain-damaged
Ultrix (no flames from DEC, I am really losing my patience with them!)
and is flakey with NFS.  I wrote the rule to use rcp.

The Makefile looks something like:

copy:	source file names...
	-if test `hostname` = nbc1; then rcp $? other_system:~scott/src/zz; fi
	-if test `hostname` = other_system; then rcp $? nbc1:~scott/src/zz; fi
	touch copy


OK, the workstation on my desk (gershwin) has my home directory NFS
mounted from nbc1 (both Suns running SunOS 4.1).  So
gershwin:~scott/src/xx/some_file is the same as
nbc1:~scott/src/xx/some_file.  If I run the above on gershwin, I get the
command:

	rcp some_file nbc1:~scott/src/zz

allegedly copying the same file into itself.  I did this several times
before I realized what I was doing.  No messages, error or otherwise.

HOWEVER, it did not destroy the copy of the file--THANKFULLY!  My
question is why?  How does rcp work so that if I mess up like above, my
8k of carefully constructed data doesn't disappear?

Thanks!

-- 
scott barman				NBC Computer Imaging
scott@nbc1.ge.com			30 Rockerfeller Plaza, Room 1615W
{philabs,crdgw1}!nbc1!scott		New York, NY  10112	+1 212/664-2787
  (This does not represent any [un]official opinions of NBC or its affiliates)

mjr@hussar.dco.dec.com (Marcus J. Ranum) (11/08/90)

In article <1990Nov5.192620.1467@nbc1.ge.com> scott@nbc1.GE.COM (Scott Barman) writes:

>I wrote and maintaining a program that has to run on both Suns and
>MicroVaxes (not my choice so save your flames).  To make sure sources
>stay the same on all machines I am using my Makefile to rcp the changed
>sources to the other machines.

	I prefer to use rdist for such things - it's even smart enough
to not stomp on top of files that you want, check last update times, etc.
I really suggest you take a look at it. To head off yet another complaint
about DEC: rdist is not part of the older releases of ULTRIX (I assume
you must be running an old release if you're getting NFS errors) :-)
but its source is available for FTP on uunet.uu.net in bsd-sources.

	One other nice thing about rdist is it lets you specify whole
directories to remote-maintain, and lets you give "except-patters" so
you don't wind up copying your VAX binaries to the Suns.

	Was that a "flame" ?

mjr.

barmar@think.com (Barry Margolin) (11/09/90)

In article <1990Nov5.192620.1467@nbc1.ge.com> scott@nbc1.GE.COM (Scott Barman) writes:
>	rcp some_file nbc1:~scott/src/zz
>
>allegedly copying the same file into itself.  I did this several times
>before I realized what I was doing.  No messages, error or otherwise.
>
>HOWEVER, it did not destroy the copy of the file--THANKFULLY!  My
>question is why?  How does rcp work so that if I mess up like above, my
>8k of carefully constructed data doesn't disappear?

I suspect you lucked out, due to asynchronous timing and caching.

"rcp srcfile host:destfile" is effectively equivalent to

	rsh host "cat >destfile" <srcfile

If the local system has all of the source file in its NFS cache, and the
cache doesn't time out too soon, this should work.

P.S.  If NBC is on the net, can I send "viewer email" to David Letterman?
--
Barry Margolin, Thinking Machines Corp.

barmar@think.com
{uunet,harvard}!think!barmar

davecb@yunexus.YorkU.CA (David Collier-Brown) (11/09/90)

barmar@think.com (Barry Margolin) writes:
>"rcp srcfile host:destfile" is effectively equivalent to
>	rsh host "cat >destfile" <srcfile
>If the local system has all of the source file in its NFS cache, and the
>cache doesn't time out too soon, this should work.

  Interesting...  I hadn't thought about the effects of caching when I said

for i in *; do
	rcp foo my_Sun3_280:/tmp/foo &
done

  I was disappointed and a bit puzzled when multiple copies of a
non-zero-size foo produced a zero-size /tmp/foo.  

--dave 
ps: I was also bemused when my perfmeter window turned solid black - I
should have suspected an r-command would be expensive (:-)).
-- 
David Collier-Brown,  | davecb@Nexus.YorkU.CA, ...!yunexus!davecb or
72 Abitibi Ave.,      | {toronto area...}lethe!dave or just
Willowdale, Ontario,  | postmaster@{nexus.}yorku.ca
CANADA. 416-223-8968  | work phone (416) 736-5257 x 22075