From owner-freebsd-questions@FreeBSD.ORG Mon Mar 15 21:23:02 2004 Return-Path: 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 EF98416A4CE for ; Mon, 15 Mar 2004 21:23:02 -0800 (PST) Received: from priv-edtnes14-hme0.telusplanet.net (outbound03.telus.net [199.185.220.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F6E343D39 for ; Mon, 15 Mar 2004 21:23:02 -0800 (PST) (envelope-from cpressey@catseye.mine.nu) Received: from catseye.biscuit.boo ([154.5.85.228]) by priv-edtnes14-hme0.telusplanet.netSMTP <20040316052302.TLHR6187.priv-edtnes14-hme0.telusplanet.net@catseye.biscuit.boo>; Mon, 15 Mar 2004 22:23:02 -0700 Date: Mon, 15 Mar 2004 21:28:24 -0800 From: Chris Pressey To: David.Bear@asu.edu Message-Id: <20040315212824.4de201a5.cpressey@catseye.mine.nu> In-Reply-To: <20040315222720.GF28684@asu.edu> References: <20040315222720.GF28684@asu.edu> Organization: Cat's Eye Technologies X-Mailer: Sylpheed version 0.9.9 (GTK+ 1.2.10; i386-portbld-freebsd4.9) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit cc: freebsd-questions@freebsd.org Subject: Re: issue with simple script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Mar 2004 05:23:03 -0000 On Mon, 15 Mar 2004 15:27:20 -0700 David Bear wrote: > I thought I had a tape issue.. Now its clear I have a script issue. > > Below is a script I use to perform level 0 dumps on all mounted file > systems. The problem seems to be that when the script runs, it does > not run as root -- even though I am root when I run it. The goal is to > cron it, but as I was testing it I ran into some problems. > > First, I can't set the MT variable as its listed below. I get an > permission denial on /dev/nrsa0. This makes no sense, since as root I > can issue the command fine. Moreover, the dump command itself fails > even thought it seems to be rendered syntactically correct. I echo'ed > all the generated commands just to make certain they are correct. For future reference, you can achieve the same effect with the -x switch. i.e. add "-x" to the first line of the script, or run the script with sh -x l0dump.sh > Here's the output of the script: > > ===================================================== > ppsrvx# ./l0dump.sh > ./l0dump.sh: /dev/nrsa0: permission denied > comp off > /sbin/dump -0u -a -b 64 -f /dev/nrsa0 /dev/ad0s1a > /sbin/dump -0u -a -b 64 -f /dev/nrsa0 /dev/da1s1d > /sbin/dump -0u -a -b 64 -f /dev/nrsa0 /dev/da0s1e > /sbin/dump -0u -a -b 64 -f /dev/nrsa0 /dev/da1s1e > /sbin/dump -0u -a -b 64 -f /dev/nrsa0 /dev/ad0s1d > /sbin/dump -0u -a -b 64 -f /dev/nrsa0 /dev/da0s1d > /sbin/dump -0u -a -b 64 -f /dev/nrsa0 /dev/ad0s1e > /dev/sa0 offline > > ====================================================== > > notice the permission denied.. > > not also 'comp off' which SHOULD be rendered as > /usr/bin/mt -f /dev/nrsa0 comp off > > but isn't. > > I'm really stumped here. > > Is there some reason why running these commands in a script would > fail, yet running them by hand works? > > ======================================================== > #!/bin/sh > AWK=/usr/bin/awk > DF=/bin/df > DMP=/sbin/dump > DEST=/dev/nrsa0 > MT="/usr/bin/mt -f " ${DEST} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I think this line is your problem. It's trying to set the variable MT to "/usr/bin/mt -f ", then run the command ${DEST}. Of course, ${DEST} isn't a command, it's a device, which isn't executable, which is why you get "permission denied." I think that if you rewrite the line as the following, it'll do what you want: MT="/usr/bin/mt -f ${DEST}" -Chris