read several inputs and if none input set to 9999


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting read several inputs and if none input set to 9999
# 1  
Old 11-10-2008
read several inputs and if none input set to 9999

need a script that goes something like this

#!/usr/bin/bash
echo "input up to TEN values, separated by spaces"
read vari1 vari2 vari3 vari4 vari5 vari6 vari7 vari8 vari9 vari10
#set null variables to 9999 (somehow?)
#now echo all variables
echo $vari1 $vari2 $vari3 $vari4 $vari5 $vari6 $vari7 $vari8 $vari9 $vari10
#end of script



now when the user runs the script, maybe they only input a couple values, say 102 and 477. they get output:
102 477 9999 9999 9999 9999 9999 9999 9999 9999
# 2  
Old 11-10-2008
Quote:
Originally Posted by ajp7701
need a script that goes something like this

Please put code inside [code] tags.
Quote:
Code:
#!/usr/bin/bash
echo "input up to TEN values, separated by spaces"
read vari1 vari2 vari3 vari4 vari5 vari6 vari7 vari8 vari9 vari10
#set null variables to 9999 (somehow?)


Code:
: "${vari1:=9999} ${vari2:=9999} ${vari3:=9999} ${vari4:=9999}
   ${vari5:=9999} ${vari6:=9999} ${vari7:=9999} ${vari8:=9999}
   ${vari9:=9999}"

Quote:
Code:
#now echo all variables
echo $vari1 $vari2 $vari3 $vari4 $vari5 $vari6 $vari7 $vari8 $vari9 $vari10
#end of script

now when the user runs the script, maybe they only input a couple values, say 102 and 477. they get output:
102 477 9999 9999 9999 9999 9999 9999 9999 9999
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read input from Keyboard, do not proceed if no input

Hi, I am working on a script, which requests users to enter input. Ex: read -p "Please enter your email id:" email I don't want users skipping this entry, this has to be mandatory.I dont want to proceed without input. I can do a check if variable $email is empty and proceed if not.But, i... (7 Replies)
Discussion started by: aravindadla
7 Replies

2. Shell Programming and Scripting

Read input files and merge them in given order and write them to input one param or one file

Dear Friends, I am looking for a shell script to merge input files into one file .. here is my idea: 1st paramter would be outfile file (all input files content) read all input files and merge them to input param 1 ex: if I pass 6 file names to the script then 1st file name as output file... (4 Replies)
Discussion started by: hyd1234
4 Replies

3. Shell Programming and Scripting

Read variable inputs

I am trying to make an interactive script. Only problem my inputs are not read and correctly channeled. Please help: Here is my code #!/bin/sh PATHSCRIPT=/home/pp/tmp #if ; then # echo "Syntax : $0 input off lat sample" # exit 1 # fi echo "Choice of Graph" echo "1 -- Type... (5 Replies)
Discussion started by: newkid.7955
5 Replies

4. Shell Programming and Scripting

Help with Bash piped while-read and a read user input at the same time

Hi I am new to writing script and want to use a Bash Piped while-read and read from user input. if something happens on server.log then do while loop or if something happend on user input then do while loop. Pseudocode something like: tail -n 3 -f server.log | while read serverline || read... (8 Replies)
Discussion started by: MyMorris
8 Replies

5. Shell Programming and Scripting

Renaming files from aaaa-zzzz to 0001-9999

Hi, I am using split in AIX to split a large file into parts, but in AIX, it names the resulting files something like newaaaa, newaaab, newaaac etc (using a-z for each) I need to rename these new0001, new0002, new0003 etc. Is there an easy way to do this? Cheers, Rob (4 Replies)
Discussion started by: say170
4 Replies

6. Programming

Using ioctl to read mice inputs

I was wondering if its possible to read mouse inputs using ioctl functions somehow ? If it is not too much of trouble can anyone write or even direct me to sample code of ioctl reading someother HID. (2 Replies)
Discussion started by: maverick_
2 Replies

7. Shell Programming and Scripting

How to read inputs from a file

Hello; Please I need to read inputs from a file change 1 or 2 things the output to another file. (1 Reply)
Discussion started by: jimoney
1 Replies

8. UNIX for Dummies Questions & Answers

How to set the File Paths for Inputs and Outputs

I have couple of shell scripts. Each shell script accepts command line argument as inputfilename. Each shell script creates a summary file, status file. All these files are stored in a particular directory...Eg InputFile is to be picked from /home/ProjectName/ftp_inputfiles/ Outputs are to... (1 Reply)
Discussion started by: Amruta Pitkar
1 Replies

9. Shell Programming and Scripting

read n number of inputs

Hello, I think its a sinple query but somehow i m stucked up here... I am trying to enter n number of inputs from the user and write them in an input file ie row wise... I tried standard commands like $echo "enter the inputs for the file" $read var1 var2 var3 var4 test1 test2... (14 Replies)
Discussion started by: er_aparna
14 Replies

10. Programming

get input whithout inputs echoing in screen

I want to write a functionz(work on command line mode) which require user input password , but I do not want the passwd echo in screen , then I should not use scanf() . Which function should I use ? Thank you for helping me (1 Reply)
Discussion started by: chenhao_no1
1 Replies
Login or Register to Ask a Question