Start Input not on next line?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Start Input not on next line?
# 1  
Old 08-31-2006
Start Input not on next line?

I'm curious also to find if it is possible to begin input in this manner

Code:
$script.sh input

where the user enters 'script.sh' but the input goes directly next to the command instead of the new line. \c doesn't seem to work but I think it should be possible.

Has anyone done this before? Its probably a normal enough requirement?
# 2  
Old 08-31-2006
Let me get this straight. Do you want to pass input as a parameter to script.sh ? If yes, then script.sh input works just fine. Else explain again.
# 3  
Old 08-31-2006
it doesn't seem to work that way for me...

my first lines are

Code:
#!/bin/sh
read variable

which automatically throws the cursor below the command waiting for input, and if I enter the input directly following the command and press enter then it sits on the next line waiting for the command still...
# 4  
Old 08-31-2006
That is how the read command works. The args passed to a shell script are labelled $1, $2, ..., $9, ${10}, ${11}... The double digit args are not available in the original bourne shell, but you can use them in the ksh and the bash shells.

About your code:
Code:
#!/bin/sh
variable=$1
echo $variable

Then run the script the same way that you are currently running it.
# 5  
Old 08-31-2006
ahhh I didn't realise that, I understood the $1 stuff but didn't realise if that was at the top of the page it automatically picked up the input.

Thanks guys am learning heaps.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies

2. Shell Programming and Scripting

How to remove part of the line from start of the line?

Hello, I am java command from a shell script which will generate the below output on the command prompt signature Base64 :... (10 Replies)
Discussion started by: chetanojha
10 Replies

3. Shell Programming and Scripting

How do i make input start with a letter?

Howdy folks, How do i make the input start with a letter and certain num of numbers and if anything else is entered it should display error for ex; a123455 is good ( exactly 7 characters) and ex: sio234234 is not good ex: b233 is not good.. ex: jlasjdlfks is not good ... (2 Replies)
Discussion started by: coolkid
2 Replies

4. Shell Programming and Scripting

Reading line by line from live log file using while loop and considering only those lines start from

Hi, I want to read a live log file line by line and considering those line which start from time stamp; Below code I am using, which read line but throws an exception when comparing line that does not contain error code tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
Discussion started by: ketanraut
2 Replies

5. Shell Programming and Scripting

Curl - input line by line from text file

Hi, I've got a text file with hundreds of lines I need to upload to an API via curl, one by one. The text file is like: 2012-08-01 10:45,124 2012-08-02 10:45,132 2012-08-03 10:45,114 I want to get curl to go through the text file sending a post for each line. like: curl --request... (0 Replies)
Discussion started by: emdeex
0 Replies

6. Shell Programming and Scripting

How to start reading from the nth line till the last line of a file.

Hi, For my reuirement, I have to read a file from the 2nd line till the last line<EOF>. Say, I have a file as test.txt, which as a header record in the first line followed by records in rest of the lines. for i in `cat test.txt` { echo $i } While doing the above loop, I have read... (5 Replies)
Discussion started by: machomaddy
5 Replies

7. Shell Programming and Scripting

sed to read line by line and input into another file

I have two files. Fileone contains text string one text string two text string three Filetwo contains Name: Address: Summary: Name: Address: Summary: Name: Address: Summary: I would like to use sed to read each line of file one and put it at the end of the summary line of file... (3 Replies)
Discussion started by: dolacap
3 Replies

8. Shell Programming and Scripting

single line input to multiple line output with sed

hey gents, I'm working on something that will use snmpwalk to query the devices on my network and retreive the device name, device IP, device model and device serial. I'm using Nmap for the enumeration and sed to clean up the results for use by snmpwalk. Once i get all the data organized I'm... (8 Replies)
Discussion started by: mitch
8 Replies

9. Shell Programming and Scripting

sed remove last 10 characters of a line start from 3rd line

hello experts, I need a sed command that remove last 10 characters of a line start from 3rd line. any suggestions? Thanks you (7 Replies)
Discussion started by: minifish
7 Replies

10. Shell Programming and Scripting

How to prompt for input & accept input in ONE line

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
Login or Register to Ask a Question