|
|
||||||
|
#1
|
|
|
|
|
Hi
Im new to unix scripting and now Im trying to get user input from stdin and this is what I did echo "enter your name: " read name and it will run with the pointer to take the stdin on the next line enter your name: _ what should I do to take put the input pointer just after the string "enter your name: " not on the next line. eg: enter your name: _ thanks a lot |
|
|
|
#2
|
|
|
|
|
On 7 Oct 2006 22:39:20 -0700, compboy
<compboyxyz> wrote: [..] > _ > > what should I do to take put the input pointer just after the string > "enter your name: " not on the next line. > eg: > > enter your name: _ > > thanks a lot > printf "enter your name: " |
|
#3
|
|
|
|
|
On 2006-10-08, compboy wrote:
> Hi > > Im new to unix scripting and now Im trying to get user input from stdin > > and this is what I did > > echo "enter your name: " > read name > > and it will run with the pointer to take the stdin on the next line > > enter your name: > _ > > what should I do to take put the input pointer just after the string > "enter your name: " not on the next line. > eg: > > enter your name: _ The read command in some shells have methods for doing it. For example, with bash there is the -p option: read -p "enter your name: " name If your shell doesn't have anything like that (read the man page), use: printf "enter your name: " read name |
|
#4
|
|
|
|
|
compboy wrote:
[..] > enter your name: > _ > > what should I do to take put the input pointer just after the string > "enter your name: " not on the next line. > eg: > > enter your name: _ > > thanks a lot very simple,like this: echo -e "enter your name:\c " read name there "\c" means not change a new line,and only works with option "-e" on.man it |
|
#5
|
|
|
|
|
On 2006-10-09, Maxim wrote:
> > compboy wrote: > > very simple,like this: > > echo -e "enter your name:\c " > read name > > there "\c" means not change a new line,and only works with option "-e" > on.man it It will not work at all in many shells. The -e option is not standard. |
|
#6
|
|
|
|
|
2006-10-8, 23:36(-04), Chris F.A. Johnson:
[...] >> echo -e "enter your name:\c " >> read name >> >> there "\c" means not change a new line,and only works with option "-e" >> on.man it > > It will not work at all in many shells. The -e option is not > standard. [...] And the standard (both POSIX and Unix) say that the above command should either output: "-e enter your name: \c<Newline>" (POSIX) or "-e enter your name: " (Unix and POSIX) An with echo -n "enter your name: " Unix: "-n enter your name: " POSIX: result unspecified, so shouldn't be used echo "enter your name: \c" is Unix conformant, but not POSIX conformant. |
|
|
| Similar Threads | |
| Best way to input from stdin? I'm writing a program that supports input from stdin. To be able to do that I tend to rely on a simple loop that tests the return of fgets(), such as the following... |
|
| Any way to take a word as input from stdin ? I searched the c.l.c archives provided by Google as Google Groups with "word input" as the key words and did not come up with anything good. C++ has std::string for taking... |
|
| How to accept input from stdin? Hi, I try to make a wrapper around an existing program, which would behave exactly the same as the original one. But my following attempt was failed. Would you pleaes let me... |
|
| Input using stdin How can I give input to a program using STDIN Suppose I want the program to take the value x=10 On some other site i found it as STDIN.read,but its not working. |
|
| Checking available input on stdin I know this has probably come up frequently, but couldn't find a satisfactory reference... I have some code which needs to read from stdin but must not block waiting for... |
|
|
All times are GMT. The time now is 11:21 PM. | Privacy Policy
|