# C Shell Script Program



## Scarface23 (Aug 4, 2004)

I need to write a C shell script that displays the following menu and prompts for one-character input to invoke a menu option, as shown.

a. List all files in the present working directory

b. Display today&#8217;s date and time

c. Invoke the shell script for Problem 14

d. Display whether a file is a &#8220;simple&#8221; file or a &#8220;directory&#8221;

e. Crate a backup file for a file

f. Start telnet session

g. Start ftp session

h. Exit

Option (c) requires that you ask the user for a list of login names. For options (d) and (e), prompt the user for file names before invoking a shell command/program. For options (f) and (g), prompt the user for a domain name (or IP address) before initiating a telnet or ftp session. The program should allow the user to try any option any number of times and should quit only when the user gives option (h) as input.


My main concern is with the telnet and ftp session, im not sure on how to set those up. If anybody could help me out, or give some suggestions that would be great thanks.

Scar


----------



## Scarface23 (Aug 4, 2004)

Ok let me slim down my problem,

I got my menu done, set up a switch statment.

My problems come with option C. -- I need to write a shell script that takes a list of login names as its arguments and displays the number of terminals that each user is logged on to in a LAN enviornment.

Then, im not sure how to start an ftp session, and im not sure how to keep the program running until its told to exit


----------



## lotuseclat79 (Sep 12, 2003)

Hi Scarface23,

Encapsulate the menu switch statement of choices in a loop which executes each choice discretely via the switch followed by returning to the top of the loop.

Place a read choice before the loop, and another read choice before the end of the loop, but before the exit from the loop so that the loop does not end but returns to the start of the loop after reading the next choice (i.e. the loop executes infinitely) until the end choice is selected which executes a goto statement beyond the loop to a label in order to exit the script.

-- Tom


----------



## Squashman (Apr 4, 2003)

Not sure how C Shell scripts work but in Bash, your Menu could be the main part of your shell script. I would use a case stament to evaluate the response from the menu. From the case statement you would call a function for each of your menu options. Once the function is done it will return to the main menu.


----------

