Current Issue


Table of contents

CD-ROM

Sys Admin and The Perl Journal CD-ROM version 12.0

Version 12.0 delivers every issue of Sys Admin from 1992 through 2006 and every
issue of The Perl Journal from 1996-2002 in one convenient CD-ROM!

Order now!

Sys Admin Magazine > Archives > 2005 > April 2005

Questions and Answers

Amy Rich

In the December issue, one of the questions covered modifying root's crontab using scp and ssh. In order for the supplied script to work correctly, each command after the ssh needs to be quoted so that it is not executed on the local machine instead of the intended target machine. Thanks to Josh Simon for catching this error. The corrected script should be:

 #!/bin/sh
 for i in host1 host2 host2 host4; do
   scp master.cron root@${i}:/location/to/crontab/file
   ssh root@${i} "chmod 0400 /location/to/crontab/file;" \
"chown root /location/to/crontab/file;" \
"crontab /location/to/crontab/file;" \
"crontab -l"
Q I'm running Solaris 9 on a V880, and I'm having an issue with a script running from cron. The script is a slightly modified version of the updatedb script that comes with locate. Here's my version of the script (available at http://www.gnu.org/licenses/licenses.html#GPL) with all of the comments and copyright information edited out for simplicity's sake:

#!/bin/sh

usage="\
Usage: updatedb [--localpaths='dir1 dir2...'] [--netpaths='dir1 dir2...']
 [--prunepaths='dir1 dir2...'] [--output=dbfile] [--netuser=user]
 [--old-format] [--version] [--help]"

old=no
for arg
do
  opt='echo $arg|sed 's/^\([^=]*\).*/\1/''
  val='echo $arg|sed 's/^[^=]*=\(.*\)/\1/''
  case "$opt" in
    --localpaths) SEARCHPATHS="$val" ;;
    --netpaths) NETPATHS="$val" ;;
    --prunepaths) PRUNEPATHS="$val" ;;
    --output) LOCATE_DB="$val" ;;
    --netuser) NETUSER="$val" ;;
    --old-format) old=yes ;;
    --version) echo "GNU updatedb version 4.1"; exit 0 ;;
    --help) echo "$usage"; exit 0 ;;
    *) echo "updatedb: invalid option $opt
$usage" >&2
       exit 1 ;;
  esac
done
     
: ${SEARCHPATHS="/"}
: ${NETPATHS=}
: ${PRUNEPATHS="/tmp /usr/tmp /var /users /usr/local/src \
  /root /proc /dev /devices /data/amanda"}

 test -z "$PRUNEREGEX" &&
  PRUNEREGEX='echo $PRUNEPATHS|sed -e 's,^,\\\(^,' -e 's, \
    ,$\\\)\\\|\\\(^,g' -e 's,$,$\\\),''

: ${LOCATE_DB=/usr/local/var/locatedb}
     
if test -d /root/tmp; then
  : ${TMPDIR=/root/tmp}
else
  : ${TMPDIR=/tmp}
fi
     
: ${NETUSER=daemon}
: ${LIBEXECDIR=/usr/local/libexec}
: ${BINDIR=/usr/local/bin}
: ${find=find}
: ${frcode=frcode}
: ${bigram=bigram}
: ${code=code}

PATH=$LIBEXECDIR:$BINDIR:/usr/ucb:/bin:/usr/bin:$PATH export PATH

if test $old = no; then
{
if test -n "$SEARCHPATHS"; then
  $find $SEARCHPATHS \
  \( -fstype nfs -o -fstype NFS -o -type d -regex "$PRUNEREGEX" \) \
    -prune -o -print
fi

if test -n "$NETPATHS"; then
  su $NETUSER -c \
  "$find $NETPATHS \\( -type d -regex \"$PRUNEREGEX\" -prune \\) \
   -o -print"
fi
} | sort -f | $frcode > $LOCATE_DB.n

				  



MarketPlace

Flowcharts from C/C++ code -- Free trial download
Understand C/C++ code in less time. A new team member ? Inherited legacy code ? Get up to speed faster with Crystal Flow for C/C++. Code-formatting improves readability. Flowcharts are integrated with code browser. Export flowcharts to Visio.

Automate Software Builds with Visual Build Pro
Easily create an automated, repeatable process for building and deploying software.

WinDev 12 - Powerful IDE
Develop 10 times faster ! ALM, IDE, .Net, RAD, 5GL, Database, 5GL, 64-bit, etc. Free Express version

Web based bug tracking - AdminiTrack.com
AdminiTrack offers an effective web-based bug tracking system designed for professional software development teams.

Wanna see your ad here?