Having trouble with a few beginner csh scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Having trouble with a few beginner csh scripts
# 1  
Old 03-25-2012
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:

Image

Chmod Toggle:

Image

Thanks!
# 2  
Old 03-26-2012
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Debugging csh scripts!?

:wall: So I have to debug some csh scripts, which to me seems like the most painful task period. So far I 'echo' in different places to get an idea of whats going on. I also know the 'csh -x script' command, BUT what do I do when inside that script there is another scipt that is run (this... (0 Replies)
Discussion started by: vas28r13
0 Replies

2. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

3. Shell Programming and Scripting

trouble executing a command in csh

Hi All!! I am having trouble in executing the following command into a c-shell script. mv "$file" "$(head -1 "$file")" The funny thing is that the same command works perfectly from the command line, but when incorporated into a "foreach loop" of a c-shell script, it shows an error -... (1 Reply)
Discussion started by: chen.xiao.po
1 Replies

4. Shell Programming and Scripting

pass parameters from perl to csh scripts

I use csh a lot but I don't really write csh scripts. Now I have a need to implement a security check (written in perl; verify an user input security code) into a csh script. Here is the senario: #csh 1. call the perl script 2. if the perl script returns 'true', pass on; if the perl... (1 Reply)
Discussion started by: Julian16
1 Replies

5. UNIX for Dummies Questions & Answers

Running CSh scripts in Bash

Hi, I have some csh scripts and I want to run them in .bashrc. I use these techniques without any success: . test.csh or csh test.csh The first one assumed that the scripts is a bash script, so showed me errors. The second one finished without giving proper result. Can anybody offer... (6 Replies)
Discussion started by: mjdousti
6 Replies

6. Shell Programming and Scripting

Beginner looking for help

Hello, I am trying to write a script that reads names from a file called input, removes names if they have the same letter next to each other and prints the others. e.g. Colin & John would be printed Garry & Lynn would be removed My thinking is that I read in each name and... (3 Replies)
Discussion started by: colinireland
3 Replies

7. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

8. Shell Programming and Scripting

alternate to set -x in csh scripts

hi all i want to debug a csh script and i give set -x for that but i get an error. is there any command similar to set -x for csh scripts? (3 Replies)
Discussion started by: sais
3 Replies

9. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them) Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Discussion started by: pollsizer
1 Replies

10. Shell Programming and Scripting

Please help. I am a beginner.

Alrigt, I need to write a shell script where it counts the number of folders and files and dispays "My home directory has 'x' files and 'y' directories." So, I was thinking of doing this. set x = `ls | wc` so, if I have 8 files and folders in my home directory, x is not 8. now, I was... (1 Reply)
Discussion started by: Lykathea Aflame
1 Replies
Login or Register to Ask a Question