Keyboard input question

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Keyboard input question
# 1  
Keyboard input question

How would I change up a script that currently has something like:
bash script
echo what's 1 2 3 4?
then using read 1 2 3 4
I type 1 2 3 4.
so in the script i can do stuff like
echo $1 $2 $3 $4
and such...

i was just doing echo "1 2 3 4"|bash script

But was wondering how could I do something where I could execute the script and have it all on one line.
bash script 1 2 3 4

I've tried looking around and haven't had much luck, I just think I'm not finding the right term to search for. If someone could point me in the right direction please.
# 2  
I don't understand this script, what does bash script do? You could put the echo on the same line with a semi-colon, ie,
bash script; echo "what's 1 2 3 4"

Do you mean 1 2 3 4 to be options? If so I'd do
echo "Please type either a 1, 2, 3, or a 4"
echo $NUMBER

# 3  
Basically, I'm writing a script where I want some user input. However rather than when running the script it outputs:
Hi, what's variable 1 2 3?

then you type.
abc xyz 123

To get the variables in the script.

You can just type it out something like this.
bash script abc xyz 123
# 4  
Can you post that section of your script?

Bash is a program and putting it all on one line as you seem to have done would run it with all those things as arguments to the bash command.
# 5  
Just got it! Smilie

Am setting up something to download some stuff with wget, move it around, fix perms etc...
I was using
echo "Enter Host User Pass : "
read host user pass

I needed:

# 6  
It works for you then?
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #140
Difficulty: Easy
Unix and the C programming language were both developed at AT&T.
True or False?

10 More Discussions You Might Find Interesting

1. Programming

Simple capturing of keyboard input without interruption

I would like to make a function or command that checks for keyboard input without interrupting the program and exits the program when a key is pressed (perhaps the 'q' key). The program below monitors and prints/executes commands upon a change in primary (mouse selection) or clipboard buffer. If... (4 Replies)
Discussion started by: bedtime
4 Replies

2. 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

3. Shell Programming and Scripting

How to get input from keyboard with watch?

Hello, i`m trying to create an network monitoring script and i dont know how to make affect that script by pressing an key from keyboard and that script runs not in while or for or any other loop, but with bash command watch for example: i have created an file (for example check) with content... (0 Replies)
Discussion started by: bacarrdy
0 Replies

4. Shell Programming and Scripting

sed execution with input from keyboard

> sed '' Hello hi Hello output How hi output ^D How > sed should take each line as input, process and output the result. In the above scenario the input is passed from keyboard and the output of 'Hello' as you can see is displayed on the screen after 'hi' is passed as input but not as... (1 Reply)
Discussion started by: loggedin.ksh
1 Replies

5. UNIX for Dummies Questions & Answers

Testing for correct user input from keyboard

What script can I use to catch errors in a shell script if user inputs alpha numeric characters instead on integers from the keyboard? (0 Replies)
Discussion started by: Pauline mugisha
0 Replies

6. Programming

How to get capture input events from keyboard and mouse

Hi, Is there any way to capture/record the input events from keyboard, as well as from mouse using C. Thanks in advance (4 Replies)
Discussion started by: yhacks
4 Replies

7. Programming

Keyboard Input

Does anyone know how do you determine the user idle time of STDIN in order to log the user out for being idle too long. I would like to write a c program to do this but I it is not clear upon how to determine idle time from keyboard input. I have found that the "who.c" source file uses the last... (4 Replies)
Discussion started by: cpaquette
4 Replies

8. Programming

Detecting Keyboard Input without return

Hi, I need a way to detect the up and down arrow key inputs for my program. I do not want to wait for the return key to be entered(so that rules out getch() and family). Also I need to process several of these inputs in parallel, by servicing each request with a thread. Is that possible? ... (4 Replies)
Discussion started by: ravneetd
4 Replies

9. Shell Programming and Scripting

Don't show keyboard input on terminal

I am developing a script that will run with '/bin/ksh' shell. The script is intended to receive a password by keyboard input, but for security reasons I would like to hide what the user is typing. The keyboard input is being caught by 'read' command. exmaple : echo "Please type your new... (1 Reply)
Discussion started by: marianor31
1 Replies

10. Shell Programming and Scripting

suppressing keyboard input

Setup Info: This User Id and Password mention below are being used with the ISQL command to connect to a sybase database so they are likely to not be the same as those that were signed on from the session. Situation: Using a korn shell, the shell prompts for a User Id and Password. During the... (1 Reply)
Discussion started by: anthreedhr
1 Replies

Featured Tech Videos