- <ENTER> in a script
- Posted by Doug Laidlaw on December 1st, 2003
I have a beginner's book which shows that instead of the program "yes" I
could use a text file with "yes" on each line as input. I have created a
file to say "no" on those principles, and it works.
I now want to input the <ENTER> key the same way. Do I use "CHR$" or
something?
Doug.
--
Registered Linux User No. 277548.
They say lightning never strikes twice in the same place. My typing is
about as accurate. Apologies for any typos that slip in. - Doug.
- Posted by Nils Petter Vaskinn on December 1st, 2003
On Mon, 01 Dec 2003 19:22:11 +1100, Doug Laidlaw wrote:
An empty line in the file.
--
NPV
"the large print giveth, and the small print taketh away"
Tom Waits - Step right up
- Posted by news@roaima.freeserve.co.uk on December 1st, 2003
Doug Laidlaw <laidlaws@myaccess.com.au> wrote:
As does running the command "yes no". Go figure :-)
Chris
- Posted by Sebastian Hans on December 1st, 2003
Doug Laidlaw <laidlaws@myaccess.com.au> wrote:
Yes and no. If you use a file, your "yes"s will run out eventually.
You can run yes '' (that's the empty string, quoted) or use a text file
with empty lines.
HTH
Seb
- Posted by Doug Laidlaw on December 1st, 2003
Sebastian Hans wrote:
your and Chris' comments I looked for man yes. The book didn't tell me it
could do anything but "y".
Doug.
--
Registered Linux User No. 277548.
They say lightning never strikes twice in the same place. My typing is
about as accurate. Apologies for any typos that slip in. - Doug.
- Posted by Vilmos Soti on December 1st, 2003
Doug Laidlaw <laidlaws@myaccess.com.au> writes:
Do you want something like
echo | read envvar
or you can create a file which has only one <ENTER> in it.
echo > enter_only
Later in your script
command < enter_only
Is it what you want?
Vilmos
- Posted by news@roaima.freeserve.co.uk on December 2nd, 2003
Vilmos Soti <vilmos@vilmos.org> wrote:
This won't work, as the read is forked into a temporary subshell -
which then can't pass its result ($envvar) back to the parent.
For this example it would generally be more efficient to write this
instead:
echo | command
(There are exceptions, mainly when command is actually a shell
script program block, where you would need the obfuscation of your
suggestion. However, unless you know why you need to do it, you probably
don't.)
Chris