issue with simple script
David Bear
David.Bear at asu.edu
Mon Mar 15 14:29:16 PST 2004
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.
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}
MOPTS='weof 1'
DOPTS='-0u -a -b 64 -f '
# -b 64 is max, will never use large value
FSS=`${DF} | ${AWK} '/dev/ {print $1}'`
echo ${MT} 'comp off'
# echo ${MT} 'blocksize 512'
for FS in ${FSS} ;
do
echo ${DMP} ${DOPTS} ${DEST} ${FS}
# ${MT} ${MOPTS}
done
echo ${MT} '/dev/sa0 offline'
echo "Please swap tapes on srvx" | mail iddwb
========================================================
--
David Bear
phone: 480-965-8257
fax: 480-965-9189
College of Public Programs/ASU
Wilson Hall 232
Tempe, AZ 85287-0803
"Beware the IP portfolio, everyone will be suspect of trespassing"
More information about the freebsd-questions
mailing list