hi ya just needed some help to validate this badboy
what i need is that the user enters a directory then it'll change to that and then print the directory. if not a valid directory the user is aksed whether they want another go, if yes they have another go, if not they menu programme reruns again. please help me !
45 print "this will change your current working directory"
47 print "please enter a directory to change to"
49 read dir junk
51 if test -d $dir
57 echo "The directory $dir does exist"
59 echo "I will now change to that directory"
61 cd $dir
print -n "You are now in the" "directory :"
67 echo "Please push enter to continue"
75 if test -f $dir
81 echo "$dir is a file not a directory"
87 echo "$dir does not exist"
89 echo "Please try again"
91 sleep 3
thanks but that doesn't answer my question any other help would be great. remember if the input isnt ma directory then they are given the question do you want another try? if yes they have another go if no then it reloads the project again.
The first thing I can suggest is to make your code more organized. Just looking at this (with line numbers and all - even though we're missing the first 40-some lines) makes my eyes want to roll back in my head...
You can do it to fit your own style, but indenting can be your friend - for example:
I don't know about you, but that's way easier for me to read... It groups each step together, so you can pretty much see what's going on in a glance.
Right now I am assuming this is homework, so I'm not going to give anything away - especially using somethng you may or may not have learned yet. But here's a hint for looping in a menu script (besides the ones mentioned other places in the forum):
use a "while" construct, and tell it to loop (almost) forever... that way, at the end of the command, it simply restarts.