Results 1 to 2 of 2
I've been trying to this script out for most of the day, and i've looked at several toutorials and I can't figure out why this isn't working.
I run into ...
- 10-18-2008 #1Just Joined!
- Join Date
- Oct 2008
- Posts
- 4
Simple Scripting Woes
I've been trying to this script out for most of the day, and i've looked at several toutorials and I can't figure out why this isn't working.
I run into a loop when the script starts, it always tries to rm file no matter what I input into the shell. and i've tried readas well.Code:-p': ' ANSWER
Code:#!/bin/bash -x while [ -f /$HOME/file ]; do echo "File exists rm?: y or n"; read ANSWER if [ $ANSWER = "y" ] then rm -r /$HOME/file echo "File removed" elif [ $ANSWER = "q"] then echo "Script exiting" exit 0 else echo "File exists, script terminating" fi done if [ !-f /$HOME/file ] then "File does not exist. Do you wish to create it? :y or n" read -p': ' ANSWER2 if [ "$ANSWER2" = "y" ] then touch file echo $ANSWER2 "File created, script terminated" else echo $ANSWER2 "File not created, script terminated" fi fi
- 10-18-2008 #2Just Joined!
- Join Date
- Oct 2008
- Posts
- 4
Sorry, I fixed it. Turns out its good to step away for a little bit.
Sorry, for the inconvenience. This can be deleted now.Code:#!/bin/bash while [ -f /$HOME/file ]; do echo "File exists rm?: y or n" read ANSWER if [ $ANSWER = "y" ] then rm -r /$HOME/file echo "File removed" elif [ $ANSWER = "q" ] then echo "Script exiting" exit 0 else echo "File exists, script terminating" exit 0 fi done if [ ! -f /$HOME/file ] then echo "File does not exist. Do you wish to create it? :y or n" read -p': ' ANSWER2 if [ "$ANSWER2" = "y" ] then touch file echo $ANSWER2 "File created, script terminated" else echo $ANSWER2 "File not created, script terminated" fi fi


Reply With Quote
