On Mon, Sep 13, 2010 at 8:59 AM, oss <oskar.schoe...@gmx.de> wrote: > Hello, > > if there any bug or what i make wrong ?
You're not quoting the command-line correctly. > I think, this is a typically bug within spaces in the command, or ... > The question is: How can i made better ? I think exec "$cmd_string" would be an improvement. > > Cincerally > Oskar Schömig > > oss@linux-hkus:~$ ~/bin/myupdatedb > PROC=myupdatedb > MEDIA_NAME=media/LM 10 2010 > DOING: sudo updatedb --prunepaths='media/LM 10 2010' > updatedb: invalid option 10 > Usage: /usr/bin/updatedb [--findoptions='-option1 -option2...'] > [--localpaths='dir1 dir2...'] [--netpaths='dir1 dir2...'] > [--prunepaths='dir1 dir2...'] [--prunefs='fs1 fs2...'] > [--output=dbfile] [--netuser=user] [--localuser=user] > [--old-format] [--dbformat] [--version] [--help] > > Report bugs to <bug-findutils@gnu.org>. > oss@linux-hkus:~$ > oss@linux-hkus:~$ nl ~/bin/myupdatedb > 1 #!/bin/bash > 2 PROC="$(basename $0)" > 3 echo PROC=$PROC > 4 AWK="$(which gawk)" > > 5 if [ -d /media/KINGSTON ]; then > 6 sudo updatedb --prunepaths='/media/KINGSTON' > 7 else > 8 mount | grep media 1>&2>/dev/null > 9 if [ $? = 0 ]; then > 10 MEDIA_NAME="$(mount | awk '{if(match($0,/media[A-Za-z0-9/ > ]+type/)) printf("%s\n", substr($0,RSTART,RLENGTH-5))}')" > 11 echo MEDIA_NAME=$MEDIA_NAME > 12 cmd_string="$(echo sudo updatedb > --prunepaths=\'${MEDIA_NAME}\')" > 13 echo "DOING: $cmd_string" > 14 exec $cmd_string > 15 else > 16 sudo updatedb > 17 fi > 18 fi > > > oss@linux-hkus:~$ > >