On Thu, 15 Mar 2001, Vineeta wrote:

> Hi,
>     I am trying to figure out what's wrong in the script that i have
> written? I am trying to copy the file to another location when the
> user says "y" to the interactive mode of rm i.e. rm -i
>
> If y,copy to another location
> else exit.
>
> Here's the code again:
> #!/bin/bash
>  echo 'Rm script follows..'
>  rm -i $1
>  if [ "$?" = "0" ]
>  then
>  cp $HOME/$1 ./trashdir
>  else
>  exit 1
>  fi
>
>
> Cheers,
> Vineeta
>
Well, rm will return error level 0 on both an answer of y or n.  It will
return an error level 1 if the file does not exist.  That is one of your
problems.  The second problem is that it will only work in your home
directory.  Any place else, and the mv command will fail.  It will also
fail if you use su to change users unless you use "su -"

Mikkel
-- 

    Do not meddle in the affairs of dragons,
 for you are crunchy and taste good with ketchup.



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to