List script problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting List script problem
# 1  
Old 04-30-2006
List script problem

Hi all,
First of all compliments on the forum here. Looks great and has lots of information, some of which I have been able to use. I am a relativ noob when it comes to Unix but already I have been fooling around with scripts for the company I work for here in switzerland!

Thanks to this forum I created following script:
Code:
#!/bin/ksh

email=$tp/email.txt
choice=0

while [ $choice -ne 4 ]
do
        clear
        echo "Bitte Email-adresse von Liste wählen:"
        echo ""
        echo "1)  urs.betscha@rhenus.ch"
        echo "2)  michael.jucker@rhenus.ch"
        echo "3)  david.temperli@rhenus.ch"
        echo ""
        echo "4)  Programm beenden!"
        echo ""
        echo   " Welche Email-adresse? \c"
        read choice
        case "$choice" in
                1 ) echo "urs.bet@rhe.ch" >&1  ;;
                2 ) echo "michael.jur@rhe.ch" > $email ;;
                3 ) echo "david.te@rhe.ch" > $email ;;
                4 ) clear; exit 1 ;;
        esac
done

works great so far. the only problem I have is that when the user makes a choice (1,2 or 3 i would like a text to come that basically says: The email address you chose was: david.t@bluewin.ch
In the case I put in >&1 which results in that I quickly see it on the screen but with the loop it is imediatly cleared again. If this was vba I would have no problem but this kinda scripting is new to me! Smilie

Or perhaps I am going about this completly wrong. The end result should be that the user makes a choice and his email address gets written into a text file which is later used in another script to define who an email is sent to.
So I would greatly appreciate it if someone could help me

Thanks
swissman24 aka David
# 2  
Old 04-30-2006
see if this works

THe changes are in color

#!/bin/ksh

email=$tp/email.txt
choice=0

while [ $choice -ne 4 ]
do
clear
echo "Bitte Email-adresse von Liste wählen:"
echo ""
echo "1) urs.betscha@rhenus.ch"
echo "2) michael.jucker@rhenus.ch"
echo "3) david.temperli@rhenus.ch"
echo ""
echo "4) Programm beenden!"
echo ""
echo " Welche Email-adresse? \c"
read choice
case "$choice" in
1 ) email="urs.bet@rhe.ch";;
2 ) email="michael.jur@rhe.ch" ;;
3 ) email="david.te@rhe.ch" ;;
4 ) clear; exit 1 ;;
esac
echo "The id you selected is $email_id"
echo "$email_id" >> $email
echo "Press a key\c"
read x #just to wait for you to press enter

done
# 3  
Old 04-30-2006
thanks for the help. Worked just fine! Smilie
KR
David
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Specifying a list name as argument and using that list in script.

Is there a way I can specify the name of a list as an argument to a shell script and then use the values of that list name in the script? I need to do this WITHOUT using case statements. Something like this: check.sh list1 #!/bin/bash list1="www.amazon.com www.google.com"... (9 Replies)
Discussion started by: gctaylor
9 Replies

2. Shell Programming and Scripting

List file name problem

For etc, I have 3 files in /testing folder apple.sh orange.sh pear.sh if I want to find out the apple.sh It easy, I can type ls -ltr *apple* Expected result: apple.sh but, the problem is coming up from my mind. How can I find the others .sh files without the file name "apple.sh"? ... (2 Replies)
Discussion started by: LoAlex
2 Replies

3. Shell Programming and Scripting

Problem in making a list with awk

Hi bodies,I am doing a list from a .txt file with awk commands but something is wrong. The .txt file looks like: 32782 28 18 32783 02 18 32784 01 18 32785 29 18 32786 25 23 32787 25 18 32788 00 18 32789 25 26 32790 02 23 32791 29 26 ... (2 Replies)
Discussion started by: Behrouzx77
2 Replies

4. Programming

unidirectional linked list pointer problem

I am trying to test some operations on a directed list. However, the declaration of a pointer is giving me trouble. I seem to have done something incorrectly because I get an error: "listtest.c:29: warning: 'p' may be used uninitialized in this function" Can anyone help? This is my code... (6 Replies)
Discussion started by: bluetxxth
6 Replies

5. Shell Programming and Scripting

Argument list too long problem

I have a huge set of files (with extension .common) in my directory around 2 million. When I run this script on my Linux with BASH, I get /bin/awk: Argument list too long awk -F'\t' ' NR == FNR { a=NR } NR != FNR { sub(".common", "", FILENAME) print a, FILENAME, $1 } '... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

6. Shell Programming and Scripting

BASH: File name part to list reference problem.

I've made a habit of including a four-letter "tail" on image file names I download from the Web, so I can both match them with IPTC Transmission References of my own making and rename them later using either a GUI renamer or a script I've written myself. Now I want to automate the process of... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

7. Shell Programming and Scripting

Create variables from directory list problem

I am trying to take a list of directories in a folder and give them a variable name. I have this working with the exception that the shell_exec command wants to place a return. Here is my code which might explain better what I am trying to do: <?php session_start(); $student1=$_SESSION;... (0 Replies)
Discussion started by: robp2175
0 Replies

8. Shell Programming and Scripting

Numerically sort problem for a long list of file name

I got a long list of file name. My input: data_1.txt data_2.txt data_3.txt data_10.txt data_21.txt data_12.txt data_4.txt My desired output: data_1.txt data_2.txt data_3.txt data_4.txt data_10.txt data_12.txt data_21.txt Does anybody got idea how to archive it? (11 Replies)
Discussion started by: patrick87
11 Replies

9. Shell Programming and Scripting

problem feeding netcat a list of hosts

Hi, I'm having difficulty in making a bash script to get netcat to scan a list of hosts and their ports from another file and could use some help. Here's an example host list, "nc.host": 192.168.2.110 22 And here's the first script I tried to feed "nc.host" into netcat: "nc1.sh" ... (3 Replies)
Discussion started by: seanovision
3 Replies

10. AIX

weird file list problem

When I do a file list in my spooler directory, I get the following information #ls -l |pg -rw-rw-rw- 1 user1 ugroups 831690 Apr 03 12:52 K6A80403125051.prn :res 2330479869879093344 ext 2330477052380546512 align -rw-rw-rw- 1 user1 ugroups 5900 Apr 03 14:19 K6A80403141858.idx :res... (8 Replies)
Discussion started by: jmmora
8 Replies
Login or Register to Ask a Question