Menu list in Unix csh - command not found


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Menu list in Unix csh - command not found
# 1  
Old 03-17-2009
Menu list in Unix csh - command not found

Hello, im taking a class of Unix and i dont really know much about it, im trying to create a list of menu a user would select from and im very lost. Basically it will have 5 options, the user will chose from:
1. list files in the pwd
2. display date and time
3. is the file file or directory
4. create a backup
5. exit

I have no idea how to do options 3 and 4, i think i did right options 1.2.5. When I try to run the file (it has the x permission now) i am getting a command not found. Any idea how to finish it? Thanks !!

This is what i have right now:


#!bin/csh
# This menu will allow user to select from a menu of options, and then perform the
# selected command. User can use options until he chooses to exit
while :
do
clear
echo ***** Select from menu *****
echo "[1] List all files in the current directory"
echo "[2] Display today's date and time"
echo "[3] Display whether a file is just a file, or if it is a directory"
echo "[4] Create a back up file"
echo "[5] Exit the menu"
echo -n "Select your choice {1-5}:"
read yourch
case $yourch in
1) echo "These are your files: "; ls -l; echo "Press Enter"; read;;
2) echo "Today is 'date', time is 'time'; echo "Press Enter"; read;;
5) exit 0 ;;
"menunix" 21 lines, 652 characters
# 2  
Old 03-17-2009
Quote:
Originally Posted by morava
Hello, im taking a class of Unix and i dont really know much about it, im trying to create a list of menu a user would select from and im very lost. Basically it will have 5 options, the user will chose from:
1. list files in the pwd
2. display date and time
3. is the file file or directory
4. create a backup
5. exit

I have no idea how to do options 3 and 4, i think i did right options 1.2.5. When I try to run the file (it has the x permission now) i am getting a command not found. Any idea how to finish it? Thanks !!

This is what i have right now:


#!bin/csh
# This menu will allow user to select from a menu of options, and then perform the
# selected command. User can use options until he chooses to exit
while :
do
clear
echo ***** Select from menu *****
echo "[1] List all files in the current directory"
echo "[2] Display today's date and time"
echo "[3] Display whether a file is just a file, or if it is a directory"
echo "[4] Create a back up file"
echo "[5] Exit the menu"
echo -n "Select your choice {1-5}:"
read yourch
case $yourch in
1) echo "These are your files: "; ls -l; echo "Press Enter"; read;;
2) echo "Today is 'date', time is 'time'; echo "Press Enter"; read;;
5) exit 0 ;;
"menunix" 21 lines, 652 characters
try reading man page of test command for your 3rd option
you can use cp or mv to create backup of file
# 3  
Old 03-18-2009
Thanks ! I tried to something but it's still not working, still getting Command not found error:


#!bin/csh
# This menu will allow user to select from a menu of options, and then perform the
# selected command. User can use options until he chooses to exit

while :
do
clear
echo ***** Select from menu *****
echo "[1] List all files in the current directory"
echo "[2] Display today's date and time"
echo "[3] Display whether a file is just a file, or if it is a directory"
echo "[4] Create a back up file"
echo "[5] Exit the menu"
echo -n "Select your choice {1-5}:"
read yourch
case $yourch in
1) echo "These are your files: "; ls -l; echo "Press Enter"; read;;
2) echo "Today is 'date', time is 'time'; echo "Press Enter"; read;;
3) echo "Is the file a file or a directory?"; -a $1; echo "File is a file, not a directory"; read;;
4) echo "Create a backfile"; mv $; echo "Press Enter"; read;;
5) exit 0 ;;
# 4  
Old 03-18-2009
#!bin/csh -> #!/bin/csh ??? Smilie

After, I don't like csh so ...
# 5  
Old 03-18-2009
The script looks more like ksh than csh. There is very little demand for "csh" nowadays.

The "case" should be terminated with an "esac".
# 6  
Old 03-18-2009
The "command not found" is a problem with bin/csh vs /bin/csh ...
This is the subject, so I just answered on the subject ...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in create menu with 3 sub menu using the case command

hi all i am a newbie to this is there any examples on creating a main menu with 3 sub menu main menu -> option a , b and c a menu -> option 1 ,2 and 3 b menu -> option 1 ,2 c menu -> option 1 ,2 i am getting headache as my code kept getting unexpected EOF ---------- Post... (0 Replies)
Discussion started by: chercm
0 Replies

2. Shell Programming and Scripting

Command not found errors when running csh script

I am trying to find the number of files whose name starts with uni. Below is the code but it is giving error. :confused: #!/bin/csh FILES_NAME ='files_list'; FILE_NAME_PATTERN = 'uni*'; NO_OF_FILES; ls -l $FILE_NAME_PATTERN > $FILES_NAME ; NO_OF_FILES = `wc -l $FILES_NAME`; echo... (3 Replies)
Discussion started by: hiten.r.chauhan
3 Replies

3. UNIX for Dummies Questions & Answers

csh command not found

I get a "command not found" error when I run the csh command. I also get this error when I start a new session since my default shell is c shell. Any pointers as to what is going on? I am trying to set some paths using the .cshrc file and need to use the csh command for this. Thanks. (1 Reply)
Discussion started by: kannyg
1 Replies

4. Shell Programming and Scripting

Scripting problem - when the file is not found i want it to return to the menu

when the file is not found i want it to return to the menu, however it carries out the next line when i hit a key I know its probably something simple can anyone help? here is my pause function: function pause(){ read -s -n 1 -p "Press any key to return to Menu . . ." echo } SCRIPT... (2 Replies)
Discussion started by: Alendrin
2 Replies

5. UNIX for Dummies Questions & Answers

Using a list menu as a variable

Hi again I have the follwing - cat ~/ABCFILE | grep "$SYSTEM" | grep "$USERNAME" What I'm looking to do is have the variable for $SYSTEM determined by the user making a selection from a numbered list. So, input 1 would be system ABC etc. I'm very puzzled as to how to go about this? Any... (3 Replies)
Discussion started by: Great Uncle Kip
3 Replies

6. Shell Programming and Scripting

Help with find command and list in a long format each found file

The purpose of those comands are to find the newest file in a directory acvrdind to system date, and it has to be recursively found in each directory. The problem is that i want to list in a long format every found file, but the commands i use produce unexpected results ,so the output lists in a... (5 Replies)
Discussion started by: alexcol
5 Replies

7. Shell Programming and Scripting

Ambiguous and Command not found Error in UNIX

Hi,All I wrote below script(Example1.sh) and i ran but i got error. it's excuted yesterday. SYSTEM_TIME=`date '+%H:%M:%S'` CMP_LOG_TIME=`head -1 runcmp-HINET.log` CMP_ENDED1=`grep 'HINET CMP ended' runcmp-HINET.log` CMP_ENDED2=`echo "HINET CMP ended"` CMP_FAILED2=`echo "HINET CMP... (2 Replies)
Discussion started by: koti_rama
2 Replies

8. UNIX for Dummies Questions & Answers

Ambiguous and Command not found Error in UNIX

Hi,All I wrote below script(Example1.sh) and i ran but it giveing error. it's excuted yesterday. SYSTEM_TIME=`date '+%H:%M:%S'` CMP_LOG_TIME=`head -1 runcmp-HINET.log` CMP_ENDED1=`grep 'HINET CMP ended' runcmp-HINET.log` CMP_ENDED2=`echo "HINET CMP ended"` CMP_FAILED2=`echo "HINET... (2 Replies)
Discussion started by: koti_rama
2 Replies

9. Shell Programming and Scripting

how can i check in csh if command found or not found ?

hello all im trying to use in sun Solaris the information received from the top command now i several machines that dont have install the top program so when im running the script im geting error saying after im running this code : set MemoryInfo = `top | grep Memory` if (... (2 Replies)
Discussion started by: umen
2 Replies
Login or Register to Ask a Question