The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sed remove last 10 characters of a line start from 3rd line minifish Shell Programming and Scripting 7 03-26-2008 01:42 PM
extract a particular start and end pattern from a line manish205 Shell Programming and Scripting 7 02-07-2008 03:18 AM
RegExp: From first occurrance to last (at line start) jjinno Shell Programming and Scripting 6 01-08-2008 01:04 PM
How to prompt for input & accept input in ONE line newbie168 Shell Programming and Scripting 2 09-27-2005 02:02 AM
using command line input in C code vannie High Level Programming 2 02-28-2002 12:47 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 08-31-2006
Registered User
 

Join Date: Aug 2006
Location: Hobart Tasmania
Posts: 58
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?
Reply With Quote
Forum Sponsor
  #2  
Old 08-31-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
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.
Reply With Quote
  #3  
Old 08-31-2006
Registered User
 

Join Date: Aug 2006
Location: Hobart Tasmania
Posts: 58
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...
Reply With Quote
  #4  
Old 08-31-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,326
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.
Reply With Quote
  #5  
Old 08-31-2006
Registered User
 

Join Date: Aug 2006
Location: Hobart Tasmania
Posts: 58
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0