Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hello, I am very new to Unix and I am working on a very hard assignment. I cannot figure out what the problem is ! I am working on a menu, a user should choose from, 5 options, but i am geting the error Command not found (script does have the x permission) Also I am not sure if i have the menu optoins set up correctly. Could someone please help me? I am in a state of panic
THanks !
Molly#!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 exitwhile :
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 ;;

The unix commands you were trying to implement were incomplete or I couldn't identify what you were doing. This at least gets the main menu working. You can probably change it from there:
#!/bin/csh while : do 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 x;; 2) echo "Today is 'date', time is 'time'"; echo "Press Enter"; read x;; 3) echo "Is the file a file or a directory?"; echo "File is a file, not a directory"; read x;; 4) echo "Create a backfile"; echo "Press Enter"; read x;; 5) exit 0 ;; *) exit 0;; esac done

Thanks ! I tried to correct it but still getting "Command not found" What this should is to allow user to select from a menu of 5 tasks and perform the selected task repeatedly until the user chooses to quit. The 3rd choice should tell the user whether the selected file is a file or a directory. This is what i have right now. Its still not working
#!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 exitwhile :
do
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 yourchcase $yourch in
1) echo "These are your files: "; ls -l; echo "Press Enter"; read x;;
2) echo "Today is 'date', time is 'time'"; echo "Press Enter"; read x;;
3) echo "Is the file a file or a directory?"; echo "File is a file, not a directory"; read x;;
4) echo "Create a backfile"; echo "Press Enter"; read x;;
5) exit 0 ;;
*) exit 0;;
esac
done

As I said, I'm not much of a csh scripter. I can tell you excuting:
ls -ld <filename>
gives:
if it's a directory, the first character is a "d'
if it's a file, the first character is a "-"This code snippet gets the first character into variable my char:
#!/usr/bin/cshset mychar=`ls -ld mydir|cut -c 1`
echo $mychar

morava, look at your first line
#!bin/bash
and look at nails first line
#!/bin/bash
can you see the difference. Hope that helps
Ravey Dave.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |