From owner-freebsd-questions Sun Aug 15 6:35:44 1999 Delivered-To: freebsd-questions@freebsd.org Received: from juno.dsj.net (sylvester.dsj.net [208.148.155.228]) by hub.freebsd.org (Postfix) with ESMTP id A680E15375 for ; Sun, 15 Aug 1999 06:35:36 -0700 (PDT) (envelope-from dsj@juno.dsj.net) Received: (from dsj@localhost) by juno.dsj.net (8.9.2/8.9.2) id JAA45969; Sun, 15 Aug 1999 09:34:24 -0400 (EDT) (envelope-from dsj) Date: Sun, 15 Aug 1999 09:34:24 -0400 From: "David S. Jackson" Cc: ilia@cgilh.chel.su, freebsd-questions@FreeBSD.ORG Subject: Re: Mount CDROM from User Account Message-ID: <19990815093424.D44880@juno.dsj.net> Reply-To: "David S. Jackson" References: <19990815090841.C44880@juno.dsj.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.3i In-Reply-To: <19990815090841.C44880@juno.dsj.net>; from David S. Jackson on Sun, Aug 15, 1999 at 09:08:41AM -0400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG So then David S. Jackson (dsj@dsj.net) said . . . > How could you do 'su -c "$mountcmd $device $mountpt"' in a script in > BSD? Something like 'su -c root "$mountcmd $device $mountpt"' ? I > didn't see an example in the manpage. Okay, I get it now. It's more similar to the SysV way than I thought: su root -c "$mountcmd $device $mountpt" So, this should work: ===SNIP=== #! /bin/sh device="/dev/wcd0c" mountpt="/cdrom" ftpmountpt="/home/ftp/pub/cdrom" mntcmd="mount -t cd9660" case $1 in -f) su root -c "$mntcmd $device $ftpmountpt" ;; -l) mount ;; -u) check=$(mount | grep /cdrom) check1=$(mount | grep /home/ftp/pub/cdrom) check2=$(mount | grep /dev/wcd0c) if [ -n "$check" ]; then echo "unmounting $check" su root -c "umount $device" elif [ -n "$check1" ]; then echo "unmounting $check1" su root -c "umount $device" elif [ -n "$check2" ]; then echo "unmounting $check2" su root -c "umount $device" else echo "$device is not mounted" fi ;; -m) su root -c "$mntcmd $device $mountpt" ;; *) echo -e "usage: cdm -f (for ftp users: requires root access) \n or -l (to show mounted directories) \n or -u (to umount /dev/wcd0c: requires root access) \n or * (to show this help resource) \n or -m (to mount to normal mount position: /cdrom -- Requires root access)" esac ===SNIP=== Let me know what you think! :-) -- David S. Jackson http://www.dsj.net =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Out ed0, through the firewall, over the analog line, into usr1, past another firewall, through the gateway, out the T-3, off core2 in Atlanta . . . nothin' but Net. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message