Having trouble with a few beginner csh scripts

Hey,

New to the forum and I just had a few questions. I'm writing two scripts that "have" to be written in csh, a menu and a chmod toggle script. I'm having trouble with both of them.

For the menu, it works but when the user picks an option (lets say 4) it will go through all the options from 1-4 until it gets to the user's choice. I want the script to immediately go to the user's choice, and I also want the user to able to return to the main menu once the script has run it's course. I haven't been able to get this working.

For my toggle script, it is essentially a chmod script that accepts arguments (filename and r,w,x etc). It works, but it has the same problem as my menu script. It goes through all the options before getting to the correct one. So let's say I wanted to do the following:

toggle testnumber execute

This would add an execute permission for the file testnumber. But instead, it adds permissions for write, read, and execute, leading me to believe there's a problem with the if/else statements.

Here is the code for both scripts. I took pictures because I don't know how to copy/paste straight out of my terminal.

Menu:

Chmod Toggle:

Thanks!

  1. Try using switch-case.
  2. To return back to main menu, put the whole thing in an infinite while-loop with an additional case to exit from loop.