Visit Our UNIX and Linux User Community


Dummie: How do I get variables mid program


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Dummie: How do I get variables mid program
# 1  
Old 05-05-2002
Dummie: How do I get variables mid program

I'm writing a simple program in unix and was wondering how mid switch I can run a program and get someone to enter variables for it i.e.:
#!/bin/csh -f
echo "If you wish to do v press v"
echo "If you wish to compile press c"
echo "If you wish to add an entry press a"
echo "If you wish to compile by name rather than formula press n"
echo "If the table needs sorting by formula press f"
echo "If you have finished all operations press x"
set valid = false

while ( $valid == false )

switch ( $< )

case v:
echo "view all"
more A.txt
MAIN
breaksw

case c:
(THIS IS THE BIT IM STUCK ON!!!!!!!!)
echo "enter the required?"
switch ( $< ) (THIS DOESN@T WORK SO HOW CAN I DO IT- when at the prompt search $1 etc works)
search $1 $2 $3 $4 $5 $6 $7 $8 $9
MAIN
breaksw

case a:
echo "ensure"
addone
MAIN
breaksw

case n:
echo "all entries sorted by name"
sort A.txt $10 | more
MAIN
breaksw
case f:
sortform
MAIN
breaksw

case x:
set valid = true
breaksw

default:
echo "Invalid response, try again"
breaksw

endsw
end

Any help would be greatly appreciated.

Rich
# 2  
Old 05-06-2002
You are using switch a second time - not what you need. Check out the read command or set a variable and use it instead. Also read the man page on switch so you understand what it is used for. Also, I've not seen 'search' before except in VMS. Check out grep.

case c:
(THIS IS THE BIT IM STUCK ON!!!!!!!!)
echo "enter the required?"
switch ( $< ) (THIS DOESN@T WORK SO HOW CAN I DO IT- when at the prompt search $1 etc works)
search $1 $2 $3 $4 $5 $6 $7 $8 $9
MAIN
breaksw

set dummy=$< instead of switch ($<)
thehoghunter
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #132
Difficulty: Easy
Many of the command line and graphical utilities in a Linux distro are very similar to a Unix system.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using env variables to run a program

Hi there, I need urgent help with a small program that is run via shell script. Unfortunately I only understand the bare basics of shell scripting and can't figure out how to do this. We have a program that tests the connection between 3 servers. I have a script that lets the program run on... (15 Replies)
Discussion started by: Pherdinand
15 Replies

2. UNIX Desktop Questions & Answers

Knowing the size and location of variables in a C program

So I need some help with this. Pardon me if I'm posting in the wrong forum, after some googling for my answer and finding nothing I found this forum. It seemed appropriate for what I was seeking. I just didnt find a forum that concerned the use of GDB. I'm learning to use the C language and GDB.... (2 Replies)
Discussion started by: Cambria
2 Replies

3. UNIX for Dummies Questions & Answers

I am not able to use variables in system command in a C program

this method is not working.I am having a problem to use variables in system command. i cannot use the variables in system command. this how i was did system("whereis command"); this method works very fine. but, i want use the commands as variable. that means i want only pass the variables.... (6 Replies)
Discussion started by: dhanda2601
6 Replies

4. UNIX for Dummies Questions & Answers

I'm a dummie!

Hi I was installing 10.04. At 38 minutes remaining it froze and stayed that way for about 2 hours. I shut it down and now It's "frozen" for lack of a better term. ubuntu screen comes up, goes to black screen with blinking cursor. Anyone? Thanks! ---------- Post updated at 08:03 PM ----------... (1 Reply)
Discussion started by: martinnod
1 Replies

5. UNIX for Dummies Questions & Answers

Small Program with variables

Hello Geniuses of the unix world. please help, stupid chemist. I have the following script that I need to create a file. Doesnt make sense unless i explain this way: I need to create a file called summary.in I would like all these lines to be inserted however in the command line I would like the... (1 Reply)
Discussion started by: gingburg
1 Replies

6. Shell Programming and Scripting

dummie ksh

Please help me with a newbie ksh question: I want a script in ksh (under Solaris 8 - SPARC) who runs a "ls -lR" command in some directory and it looks after all the files with the same date as the current one and/or created in the last 24 hours (or N hours). The script should do: - if no... (3 Replies)
Discussion started by: heartwork
3 Replies

7. Shell Programming and Scripting

How to access the C program variables in shell script

hi I wanted to access the C program variables in shell script. This script is called from the same C program. What are the ways in which i can access variables thankx (3 Replies)
Discussion started by: bhakti
3 Replies

8. Shell Programming and Scripting

Passing shell variables to awk program..

Hello, Can we pass shell variables like $PATH etc. to a awk program part for example, awk ' { fieldValue=$PATH .... }' file (1 Reply)
Discussion started by: Vishnu
1 Replies

9. UNIX for Advanced & Expert Users

Dump program variables

Hi, Wish if could provide some clues. How do I dump all the C program variables(global) into say a file with their names and the values. So that when I restart the application again I could use this same file for reinitializing.Is this possible? Thanks, Reji (1 Reply)
Discussion started by: rejise
1 Replies

10. UNIX for Dummies Questions & Answers

Please help this Dummie

I am trying to integrate a Digital Unix Alpha server in a LAN that contains several NT severs. Could someone give me some advise on how to integrate Alpha server, so I can contact the Alpha from any NT and visa versa. Thanks! (1 Reply)
Discussion started by: Rmeyvogel
1 Replies

Featured Tech Videos