Sponsored Content
Full Discussion: help making loops
Top Forums Shell Programming and Scripting help making loops Post 302262515 by afriend on Thursday 27th of November 2008 08:06:46 PM
Old 11-27-2008
help making loops

I feel like what I need to do, would be best accomplished with a loop.

However I dont have the slightest idea how to set that up.

The script is part of a interactive shell, for making settings to a Mac OS X server.

This particular part is in regards to disabling files services.

Code:
#!/bin/bash

clear
echo "Turn of Unused File Sharing Services"
echo
PS3='Please enter a choice from the above menu: '


stoplist=`cat <<EOT

AFP
SMB
FTP
NFS

EOT`

turnoffFunction ()
{
select CHOICE in ${stoplist[*]} Quit
do
    case "$CHOICE" in
    "") echo Hit Enter to see menu again!
	continue
	;;
    Quit) break			# exit the loop
    	;;
    *)	serveradmin stop $CHOICE |more
	;;
    esac

}

choiceFunction ()
{
echo -n "Would you like to turn off any more File Sharing Services? [y|n]"
read answer

if [ "$answer" = "y" ]; then
	turnoffFunction
else
	echo `date`
fi
}

turnoffFunction
choiceFunction

I want the user to have to ability to choose all of the choices if thats what they want to do.

The easy way out is just to use the two functions the total number of options available. But if they dont need to disable all the options, then i dont want to force them to go thru more then they have too.

Hopefully that makes since?

And if its not obvious, must of that code I borrowed.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

loops in loops

ok, i tried to write a script called purge.sh which searches current process' for a specified user running a process with a specified keyword. it also prompts the user to see how many times to purge for the specified process and how many different processes they wish to do this to.it worked until... (11 Replies)
Discussion started by: Blip
11 Replies

2. Shell Programming and Scripting

no more loops

Hello Guys I need some help with my script I'm not very good at this, hope you can point me in the right direction. My idea, to write a file with some router commands and use it on a script for me to run on a demand basis, ( or added to the cron, if I get it to work). The below script works,... (5 Replies)
Discussion started by: tony3101
5 Replies

3. UNIX for Dummies Questions & Answers

While Loops

I'm trying to create a loop that will prompt the user for 15 values, not forcing them to enter all 15. If the user enters through one or more of the prompts the null value needs to be converted to 0, otherwise set the parameter = to the value entered: ex. Please enter file no #1: 17920 ... (4 Replies)
Discussion started by: vdc
4 Replies

4. Shell Programming and Scripting

Help with the 2 for loops

#!/bin/bash IFS=$'\n' A= a c b t g j i e d B= t y u i o p counter=0 found="" for i in $(cat $A) do for j in $(cat $B) do if then found="yes" fi done if then (1 Reply)
Discussion started by: vadharah
1 Replies

5. UNIX for Dummies Questions & Answers

For Loops

Hi everyone, I have a question regarding for loops. I am writing a BASH shell script that will contain multiple loops. These loops all involve looping with a count: for (( a=0; a <=10; a++ )); do echo $a done If none of my multiple loops relate to each other throughout the script,... (3 Replies)
Discussion started by: msb65
3 Replies

6. UNIX for Dummies Questions & Answers

loops with tr

Hello, I'm not sure if this is more appropriate for the 'unix for dummies' or the 'unix for experts' forum because I'm new to this forum and this is the second topic I've discussed, but if you could let me know which one was more appropriate for something like this, please do! So in tr (an... (2 Replies)
Discussion started by: juliette salexa
2 Replies

7. UNIX for Dummies Questions & Answers

Help with for loops

Hi, I am starting to enhance my scripting knowledge and need some assistance with simple 1 line for loops. This may help to do a mass permissions change on a big apache doc root while I have an insane customer on my phone. What is the best resource to learn this skill and what are some that... (5 Replies)
Discussion started by: Oshie74
5 Replies

8. Homework & Coursework Questions

If and Loops

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: In this script you will take a directory as input from the user and change the end of line sequence from a Unix... (1 Reply)
Discussion started by: Pcarson
1 Replies

9. UNIX for Dummies Questions & Answers

Need help with for loops

Why wont my for statements work? Im trying to get this script to swich to a user an if you put in a start/stop/or restart paramater to do just that for each user. I commented out the actual start/stop actions to test it just by using echos and not do anything hasty in the environment but it... (0 Replies)
Discussion started by: LilyClaro
0 Replies
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 05:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy