View Single Post

  #4 (permalink)  
Old 03-02-2007, 07:08 AM
borsel borsel is offline
Junior Member
 
Join Date: Mar 2007
Posts: 1
Rep Power: 0
borsel
Default Re: Shell script to delete a file with a dialog utility

Quote:
Originally Posted by shankar100
Hello,

I am learning shell script by following online documentation of vivek (freeos.com). I need some help to fix the problem. please see the below script.

dialog --title "Input- Delete a file" --backtitle "Welcome to linux dialog utility" --inputbox "Enter the file name to delete" 8 60 2>/home/shankar/name
sel=$?
out=`cat /home/shankar/name`
case $sel in
0) rm $out; echo "file is deleted";;
1) echo "You pressed cancel";;
255) echo "You pressed ESC";;
esac
rm /home/shankar/name

The above script will delete the given file, what if there is no file exists ( if (! -f $out) ). The script should check for the file on the system , if finds delete that otherwise it leave a message "no such file exists". Please help me


Hi,

could you please tell me how you got the dialog utility .I am running ubuntu , not redhat.

thanks
Reply With Quote