Multiple arguments to read


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Multiple arguments to read
# 1  
Old 03-18-2013
Multiple arguments to read

I am developing a script where 3 other scripts are included.

This is a graph related script.

COMPLETE IDEA:

-There are 3 different graph scripts. I would like to create a master graph with all 3 in one.

-User chooses the type of graph

-User is asked to enter the required auguments ( File name, Offset, latency and sampling are common to all 3). But 2 graphs should have a choice of mode for latency calculation.

PROBLEM:
1 How do i read the required arguments.

2 once i read them, how would i pass it to the corresponding graph script?

Please help
# 2  
Old 03-18-2013
Code:
printf "Input something: "
read SOMETHING
./myscript $SOMETHING

# 3  
Old 03-19-2013
There are multiple arguments as mentioned before:

PHP Code:
For Eg:
Enter FileName Offset Latency sampling 
how do i read 4 or more inputs in the same format above?
# 4  
Old 03-19-2013
Code:
 
echo "Enter FileName Offset Latency sampling"
read filename offset latency sampling

# 5  
Old 03-19-2013
it would be more appropriate if you try using the
Code:
 getopts

instead of taking input in very simple format and then print the help menu once the user inputs a wrong data...
# 6  
Old 03-29-2013
is there an example of getopts please.

I tried what Pikk45 said, and it dint work.

Please help.
# 7  
Old 03-29-2013
man getopt?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

[BASH] Read pipe of unkown number of arguments?

Heays So i have that script to which i'd like to pipe (rather than just regular arguments) some data from another virtual output command. Simplified: echo * | script.sh When i know how many args i expect, i can handle this simple by: && \ read ONE TWO && \ set ONE TWO echo "$1 : $2... (7 Replies)
Discussion started by: sea
7 Replies

2. Shell Programming and Scripting

[Solved] Read and validate input arguments

Hi, I need to get input arguments, as well as validate them. This is how I'm reading them: #!/bin/bash args="$@" # save arguments to variable ## Read input arguments, if so while ; do case $1 in -v | --verbose ) verbose=true;; -z | --gzip ) compression="gz";; ... (3 Replies)
Discussion started by: AlbertGM
3 Replies

3. Shell Programming and Scripting

Need help to read command line arguments?

I am new to schell scripting . My objective is to write a ksh shell script that performs following tasks: - 1. Script reads all command line arguments (arguments are file names) and checks if it contains charachters "abc" in it. 2. If it contains "abc" it will execute a binary file xyz <command... (3 Replies)
Discussion started by: acmilan
3 Replies

4. Programming

Changing the way arguments are read from program

I have the following piece of code. Currently the command line arguments are passed as shown below using the "= "sign. I capture the name of the argument, for example vmod and it's corresponding user parameter which is jcdint-z30.cmd. ./raytrac vmod=jcdint-z30.cmd srFile=jcdint.sr Now I want... (12 Replies)
Discussion started by: kristinu
12 Replies

5. Shell Programming and Scripting

bash read within function with arguments

I have trouble getting this logic to work #!/bin/bash function assign_var(){ while do read -p "$2 :" $3 done } assign_var '$IPADDRESS' ipaddress IPADDRESS Basicly, i want to make sure that entry is made (i can add more sophisticated checks later), but the idea is to recycle... (11 Replies)
Discussion started by: serverchief
11 Replies

6. Programming

Read arguments from a config file in C

Hello everybody, I'm coding a program in C and i'm getting troubles with this. I need to read a config file and store the arguments into individual variables, let's say the config file looks like the following: #This is the configuration file... 192.168.0.1 A1:B1:C1:D1:E1:F1 192.168.0.2... (2 Replies)
Discussion started by: semash!
2 Replies

7. Shell Programming and Scripting

Read multiple arguments in for loop each time

Hi, Guys I am new to shell programming and just get stuck with one simple question. please kindly help. According to the tutorial here, we can do something like for NODE in "ABC 10" "EFG 20" do set -- $NODE echo "letter is $1, number is $2" done And the result will... (3 Replies)
Discussion started by: yuanli
3 Replies

8. Shell Programming and Scripting

How to read arguments to make command

In the make file update updateq: ------------------- ---------- i want the makefile to display some messages when user gives "make update", but totally quite wehn user enters "make updateq". Can u tell me how to read these argument in makefile. $1 doesnt work:( (3 Replies)
Discussion started by: vikashtulsiyan
3 Replies

9. Programming

read arguments from shell

I have to write a C program using sys call (read, no fread) to read from shell all the parameters, without know how many are them. I tryed in some ways, but I have no success. Any Idea? Can I use read to read from stdin? (1 Reply)
Discussion started by: DNAx86
1 Replies

10. Shell Programming and Scripting

read number of arguments in c shell

I am writing script in c shell and using this script to read the command line arguments, but it is not working. Pl. someone let me know what is the problem. #!/bin/csh -f if ($#argv <> 2) then echo "you must give exactly two parameters" else set name1 = $argv ... (1 Reply)
Discussion started by: skumar11
1 Replies
Login or Register to Ask a Question