Date: Sun, 14 Jul 2002 16:28:20 -0400 From: Andrew J Caines <A.J.Caines@halplant.com> To: FreeBSD Questions <FreeBSD-Questions@FreeBSD.org> Subject: Re: weird things happening here Message-ID: <20020714202820.GN309@hal9000.halplant.com> In-Reply-To: <F142k51EAJJ8jO5TeZ5000109a7@hotmail.com> References: <F142k51EAJJ8jO5TeZ5000109a7@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020714202820.GN309>