|
Home > Archive > Unix Shell > November 2005 > Scription Question on Output
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Scription Question on Output
|
|
| amerar@iwc.net 2005-11-14, 5:56 pm |
| Hi,
I have a long shell script I wrote to automate some tasks. Some of the
lines in this script echo a response into a command, such as 'echo Y |
<program name>'.
All works fine. However, I've seen problems arise if the number of
responses piped into a command is different than what the command is
expecting. In fact, say the command needed 2 responses this time
around, and I only provided 1 on my 'echo' pipe.........
The script goes into an infinite loop printing error messages on the
screen. Is there any way to detect this, or capture what the script is
doing and abort gracefully, rather than having 1 million lines scroll
while it ignores my ctrl-c attempts?
Thanks.
| |
| Bill Marcum 2005-11-14, 5:56 pm |
| On 14 Nov 2005 11:01:49 -0800, amerar@iwc.net
<amerar@iwc.net> wrote:
> Hi,
>
> I have a long shell script I wrote to automate some tasks. Some of the
> lines in this script echo a response into a command, such as 'echo Y |
><program name>'.
>
> All works fine. However, I've seen problems arise if the number of
> responses piped into a command is different than what the command is
> expecting. In fact, say the command needed 2 responses this time
> around, and I only provided 1 on my 'echo' pipe.........
>
> The script goes into an infinite loop printing error messages on the
> screen. Is there any way to detect this, or capture what the script is
> doing and abort gracefully, rather than having 1 million lines scroll
> while it ignores my ctrl-c attempts?
>
set -ex
{ echo x; echo y } | program_name
--
There is an order of things in this universe.
-- Apollo, "Who Mourns for Adonais?" stardate 3468.1
| |
| amerar@iwc.net 2005-11-14, 5:56 pm |
|
Unsure of what your resolution is supposed to do......can you explain
please??
| |
| Ed Morton 2005-11-14, 5:56 pm |
| amerar@iwc.net wrote:
> Unsure of what your resolution is supposed to do......can you explain
> please??
>
read this: http://cfaj.freeshell.org/google
| |
| Barry Margolin 2005-11-14, 8:51 pm |
| In article <1131999572.128464.239240@g49g2000cwa.googlegroups.com>,
"amerar@iwc.net" <amerar@iwc.net> wrote:
> Unsure of what your resolution is supposed to do......can you explain
> please??
I assume you're talking about this recommendation:
{ echo x; echo y } | program_name
It provides two inputs to the program, first x and then y.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
| |
| Bill Marcum 2005-11-15, 2:51 am |
| On 14 Nov 2005 12:19:32 -0800, amerar@iwc.net
<amerar@iwc.net> wrote:
>
> Unsure of what your resolution is supposed to do......can you explain
> please??
>
set -ex
"e" causes the script to stop if there is an error (if a command returns
a non-zero status)
"x" prints each command before executing
{ echo x; echo y } | command
if "command" requires two lines of input, this is one way to do it.
--
My parents went to Niagara Falls and all I got was this crummy life.
|
|
|
|
|