02-10-2004
Accept user input - only numbers
I have a situation where I want the user to enter only numbers in response to a READ command. I have some validation to restrict the number to be between 1 and 12, but if the user type in some characters the script echoes some error message and goes to the next command. Below is a snippet of the script. Thanks in advance for any help.
period=0
while [ $period -lt 1 ] || [ $period -gt 12 ]
do
echo Export Period?
read period
done
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Is there any way to makesure that the input from the user is all numbers?
thankz (5 Replies)
Discussion started by: XXXXXXXXXX
5 Replies
2. Shell Programming and Scripting
Dear All,
I got a table creation file in a standard format. I need to accept parameters from the user & then based on the input change the data in the file. For. eg. i will accept the database name, dbspace name & user name from the user and accordingly change the same in the table creation... (2 Replies)
Discussion started by: lloydnwo
2 Replies
3. Shell Programming and Scripting
hi,
am a new learner to shell programming.
i have a script which will prompt for user to key in their name & display their name afterwards.
script
=====
echo "Pls enter your name:"
read name
echo "Your name is $name."
output
=====
Pls enter your name:
Bob
Your name is Bob.
what... (2 Replies)
Discussion started by: newbie168
2 Replies
4. UNIX for Dummies Questions & Answers
I am trying to write a one line command for Oracle grid control. I am using a semi-colon to separate the commands. But, I am having a problem with a shell script accepting input. Wondering if you can help.
Here is what I am trying to do:
(PGPRD5432)@prd01:/> cd /export/home/postgres ##... (3 Replies)
Discussion started by: rexmabry
3 Replies
5. UNIX for Dummies Questions & Answers
how would i accept user input from the keyboard? (2 Replies)
Discussion started by: JamieMurry
2 Replies
6. Shell Programming and Scripting
Hi All,
I am trying to write a script in which I need to accept multiple value in the same variable.
The case Is that I have put a FOR loop and inside the FOR loop I am accepting a variable value. And I require all the values which gets inputted in the variable.
To be... (5 Replies)
Discussion started by: rahulmittal87
5 Replies
7. Shell Programming and Scripting
Dear All,
The sqlplus 'Accept' command is not waiting for user input when I include the command within a shell script.
Note: The 'Accept' command is working fine if I execute it in a SQLPLUS Prompt.
Please fins the below sample script which i tried.
SCRIPT:
--------
#!... (4 Replies)
Discussion started by: little_wonder
4 Replies
8. Programming
Hi
I want to accept multiple lines input with spaces from User and i have a working code like this.
char sRes;
char sReq;
printf("Please enter request:");
scanf("%",sReq); /* Accept the input from user */
printf("\nPlease enter response:");
scanf("%",sRes);
but the... (4 Replies)
Discussion started by: AAKhan
4 Replies
9. Shell Programming and Scripting
echo (some info) read? <&1(not working for me) (1 Reply)
Discussion started by: robin_simple
1 Replies
10. Shell Programming and Scripting
I want a shell script that accepts user input simultaneously when performing other tasks. Example: A shell script should echo some messages on the console and when the user presses some keys it should respond to that action.
say, when user presses the key
A - more information should be printed... (2 Replies)
Discussion started by: Arun_Linux
2 Replies
LEARN ABOUT DEBIAN
scsi_readcap
SCSI_READCAP(8) SG3_UTILS SCSI_READCAP(8)
NAME
scsi_readcap - do SCSI READ CAPACITY command on disks
SYNOPSIS
scsi_readcap [--brief] [--help] [--long] [--verbose] DEVICE [DEVICE]*
DESCRIPTION
This Bourne shell script calls the sg_readcap utility on each given DEVICE. This will send a SCSI READ CAPACITY command to each DEVICE.
The default action of this script is to send the 10 byte cdb READ CAPACITY(10) command to each DEVICE. If a response indicates the number
of blocks is greater than or equal to '2**32 - 1' then the READ CAPACITY(16) is sent and its response is output.
OPTIONS
Arguments to long options are mandatory for short options as well.
-b, --brief
shortens the output to two hexadecimal numbers, both prefixed by '0x'. The first number is the number of blocks available and the
second is the size of each blocks in bytes (e.g. '0x12a19eb0 0x200'). If an error is detected '0x0 0x0' is output and the script
continues if there are more DEVICEs.
-h, --help
print out the usage message then exit.
-l, --long
the default is to send the READ CAPACITY(10) command (i.e. the 10 byte cdb variant). When this option is given the READ CAPACITY(16)
command is sent. The latter command yields more information in its response.
-v, --verbose
increase level or verbosity.
EXIT STATUS
The exit status of this script is 0 when it is successful. Otherwise the exit status is that of the last sg_readcap utility called. See the
sg3_utils(8) man page.
AUTHORS
Written by D. Gilbert
COPYRIGHT
Copyright (C) 2009 Douglas Gilbert
This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR-
POSE.
SEE ALSO
sg_readcap (sg3_utils)
sg3_utils-1.28 October 2009 SCSI_READCAP(8)