From owner-freebsd-questions Sun Jul 14 13:28:26 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 00CDF37B401 for ; Sun, 14 Jul 2002 13:28:22 -0700 (PDT) Received: from mail.halplant.com (ip68-100-145-31.nv.nv.cox.net [68.100.145.31]) by mx1.FreeBSD.org (Postfix) with ESMTP id E4C9543E81 for ; Sun, 14 Jul 2002 13:28:21 -0700 (PDT) (envelope-from A.J.Caines@halplant.com) Received: by mail.halplant.com (Postfix, from userid 1001) id AA8C820A; Sun, 14 Jul 2002 16:28:20 -0400 (EDT) Date: Sun, 14 Jul 2002 16:28:20 -0400 From: Andrew J Caines To: FreeBSD Questions Subject: Re: weird things happening here Message-ID: <20020714202820.GN309@hal9000.halplant.com> Reply-To: Andrew J Caines Mail-Followup-To: FreeBSD Questions References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: H.A.L. Plant X-PGP-Fingerprint: C59A 2F74 1139 9432 B457 0B61 DDF2 AA61 67C3 18A1 X-Powered-by: FreeBSD 4.6-STABLE X-URL: http://halplant.com:88/ Importance: Normal User-Agent: Mutt/1.5.1i Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG uwi, > uwiman* pwd && id > /usr/stuff/3/packages/All > uid=0(root) gid=0(wheel) groups=0(wheel), 2(kmem), 3(sys), 4(tty), > 5(operator), 20(staff), 31(guest) > uwiman* cp drm-kmod-0.9.5_1.tgz test | exec mkdir test > mkdir: test: File exists > uwiman# id > uid=777(uwiman) gid=0(wheel) groups=0(wheel) > > uwiman* cp drm-kmod-0.9.5_1.tgz | exec mkdir test > usage: cp [-R [-H | -L | -P]] [-f | -i] [-pv] src target > cp [-R [-H | -L | -P]] [-f | -i] [-pv] src1 ... srcN directory > uwiman# id > uid=777(uwiman) gid=0(wheel) groups=0(wheel) You're really confused about how shell operations work. | is a pipe - it connects STDOUT from the command on the left of it to STDIN to the command on the right. && and || are conditionals - they make the command on the right depend on the success (&&) or failure (||) of the command on the left. exec replaces the current process with the command which follows (instead of running it as a subprocess). I think you are trying to copy a file into a directory and create the directory if it doesn't exist. To do this, you want to use something like this: # [ -d test ] || mkdir test ; cp drm-kmod-0.9.5_1.tgz test > As you might have already noticed, me [root] suddenly becomes a regular > mortal [user]. Why? Because you replaced root's shell with "mkdir test". When that command finished you went back to the regular user's shell from which you su'ed. -Andrew- -- _______________________________________________________________________ | -Andrew J. Caines- Unix Systems Engineer A.J.Caines@halplant.com | | "They that can give up essential liberty to obtain a little temporary | | safety deserve neither liberty nor safety" - Benjamin Franklin, 1759 | To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message