Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.misc > #7825 > unrolled thread

how to I echo debugging remarks inside a function?

Started byTodd <Todd@invalid.invalid>
First post2013-04-09 19:33 -0700
Last post2013-04-09 19:49 -0700
Articles 8 — 3 participants

Back to article view | Back to comp.os.linux.misc


Contents

  how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-09 19:33 -0700
    Re: how to I echo debugging remarks inside a function? Lew Pitcher <lpitcher@teksavvy.com> - 2013-04-09 22:46 -0400
      Re: how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-09 19:55 -0700
      Re: how to I echo debugging remarks inside a function? Richard Kettlewell <rjk@greenend.org.uk> - 2013-04-10 09:12 +0100
        Re: how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-10 11:28 -0700
          Re: how to I echo debugging remarks inside a function? Lew Pitcher <lpitcher@teksavvy.com> - 2013-04-10 16:20 -0400
            Re: how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-12 11:47 -0700
    Re: how to I echo debugging remarks inside a function? Todd <Todd@invalid.invalid> - 2013-04-09 19:49 -0700

#7825 — how to I echo debugging remarks inside a function?

FromTodd <Todd@invalid.invalid>
Date2013-04-09 19:33 -0700
Subjecthow to I echo debugging remarks inside a function?
Message-ID<kk2isa$t64$1@dont-email.me>
Hi All,

I want to echo debugging statements inside a function
the returns its value as an echo.  But I do not want
the debugging echo to be part of the return echo.  I want
the debugging echo to go to the screen instead.

#!/bin/bash
abc () {
    echo "I want this to go to the screen"
    echo "This goes to the return string"
}
echo "-->$(abc)<--"

If you run the above, you will notice everything
goes to the return variable.

Many thanks,
-T

[toc] | [next] | [standalone]


#7826

FromLew Pitcher <lpitcher@teksavvy.com>
Date2013-04-09 22:46 -0400
Message-ID<lo49t.185675$m21.95467@newsfe02.iad>
In reply to#7825
On Tuesday 09 April 2013 22:33, in comp.os.linux.misc, Todd@invalid.invalid
wrote:

> Hi All,
> 
> I want to echo debugging statements inside a function
> the returns its value as an echo.  But I do not want
> the debugging echo to be part of the return echo.  I want
> the debugging echo to go to the screen instead.
> 
> #!/bin/bash
> abc () {
>     echo "I want this to go to the screen"
>     echo "This goes to the return string"
> }
> echo "-->$(abc)<--"

To get text to appear on your terminal, no matter where stdout & stderr are
redirected to, redirect the required output to /dev/tty 

As in...
  #!/bin/bash
  abc () {
      echo "I want this to go to the screen" >/dev/tty
      echo "This goes to the return string"
  }
  echo "-->$(abc)<--"

HTH
-- 
Lew Pitcher
"In Skills, We Trust"

[toc] | [prev] | [next] | [standalone]


#7828

FromTodd <Todd@invalid.invalid>
Date2013-04-09 19:55 -0700
Message-ID<kk2k61$33l$1@dont-email.me>
In reply to#7826
On 04/09/2013 07:46 PM, Lew Pitcher wrote:
> On Tuesday 09 April 2013 22:33, in comp.os.linux.misc, Todd@invalid.invalid
> wrote:
>
>> Hi All,
>>
>> I want to echo debugging statements inside a function
>> the returns its value as an echo.  But I do not want
>> the debugging echo to be part of the return echo.  I want
>> the debugging echo to go to the screen instead.
>>
>> #!/bin/bash
>> abc () {
>>      echo "I want this to go to the screen"
>>      echo "This goes to the return string"
>> }
>> echo "-->$(abc)<--"
>
> To get text to appear on your terminal, no matter where stdout & stderr are
> redirected to, redirect the required output to /dev/tty
>
> As in...
>    #!/bin/bash
>    abc () {
>        echo "I want this to go to the screen" >/dev/tty
>        echo "This goes to the return string"
>    }
>    echo "-->$(abc)<--"
>
> HTH
>

We both figured it out at the same time.  Man that echo
inside a function to debug is a frustrating problem.  :'(

Thank you!

[toc] | [prev] | [next] | [standalone]


#7829

FromRichard Kettlewell <rjk@greenend.org.uk>
Date2013-04-10 09:12 +0100
Message-ID<87fvyypzwr.fsf@araminta.anjou.terraraq.org.uk>
In reply to#7826
Lew Pitcher <lpitcher@teksavvy.com> writes:
> Todd@invalid.invalid wrote:

>> I want to echo debugging statements inside a function
>> the returns its value as an echo.  But I do not want
>> the debugging echo to be part of the return echo.  I want
>> the debugging echo to go to the screen instead.
>> 
>> #!/bin/bash
>> abc () {
>>     echo "I want this to go to the screen"
>>     echo "This goes to the return string"
>> }
>> echo "-->$(abc)<--"
>
> To get text to appear on your terminal, no matter where stdout & stderr are
> redirected to, redirect the required output to /dev/tty 

That’s a terrible idea, the process may not have a controlling terminal.
The best places to send debug output are stderr or a logfile.  (See ‘set
-x’ if you want precedent for using stderr.)

-- 
http://www.greenend.org.uk/rjk/

[toc] | [prev] | [next] | [standalone]


#7837

FromTodd <Todd@invalid.invalid>
Date2013-04-10 11:28 -0700
Message-ID<kk4arg$20c$1@dont-email.me>
In reply to#7829
On 04/10/2013 01:12 AM, Richard Kettlewell wrote:
> Lew Pitcher <lpitcher@teksavvy.com> writes:
>> Todd@invalid.invalid wrote:
>
>>> I want to echo debugging statements inside a function
>>> the returns its value as an echo.  But I do not want
>>> the debugging echo to be part of the return echo.  I want
>>> the debugging echo to go to the screen instead.
>>>
>>> #!/bin/bash
>>> abc () {
>>>      echo "I want this to go to the screen"
>>>      echo "This goes to the return string"
>>> }
>>> echo "-->$(abc)<--"
>>
>> To get text to appear on your terminal, no matter where stdout & stderr are
>> redirected to, redirect the required output to /dev/tty
>
> That’s a terrible idea, the process may not have a controlling terminal.
> The best places to send debug output are stderr or a logfile.  (See ‘set
> -x’ if you want precedent for using stderr.)
>

Thank you!

#!/bin/bash
abc () {
    echo "I want this to go to the screen" > "/dev/tty"
    echo "I want this to go to the screen too" > "/dev/stderr"
    echo "This goes to the return string"
}
echo "-->$(abc)<--"


$ ./EchoTest
I want this to go to the screen
I want this to go to the screen too
-->This goes to the return string<--

[toc] | [prev] | [next] | [standalone]


#7838

FromLew Pitcher <lpitcher@teksavvy.com>
Date2013-04-10 16:20 -0400
Message-ID<iQj9t.185719$m21.60917@newsfe02.iad>
In reply to#7837
On Wednesday 10 April 2013 14:28, in comp.os.linux.misc,
Todd@invalid.invalid wrote:

> On 04/10/2013 01:12 AM, Richard Kettlewell wrote:
>> Lew Pitcher <lpitcher@teksavvy.com> writes:
>>> Todd@invalid.invalid wrote:
>>
>>>> I want to echo debugging statements inside a function
>>>> the returns its value as an echo.  But I do not want
>>>> the debugging echo to be part of the return echo.  I want
>>>> the debugging echo to go to the screen instead.
>>>>
>>>> #!/bin/bash
>>>> abc () {
>>>>      echo "I want this to go to the screen"
>>>>      echo "This goes to the return string"
>>>> }
>>>> echo "-->$(abc)<--"
>>>
>>> To get text to appear on your terminal, no matter where stdout & stderr
>>> are redirected to, redirect the required output to /dev/tty
>>
>> That’s a terrible idea, the process may not have a controlling terminal.
>> The best places to send debug output are stderr or a logfile.  (See ‘set
>> -x’ if you want precedent for using stderr.)
>>
> 
> Thank you!
> 
> #!/bin/bash
> abc () {
>     echo "I want this to go to the screen" > "/dev/tty"
>     echo "I want this to go to the screen too" > "/dev/stderr"
>     echo "This goes to the return string"
> }
> echo "-->$(abc)<--"
> 
> 
> $ ./EchoTest
> I want this to go to the screen
> I want this to go to the screen too
> -->This goes to the return string<--

But...
  ./EchoTest 2>debug.log
will only show
  I want this to go to the screen
  -->This goes to the return string<--
and the line
  I want this to go to the screen too
will appear in the file ./debug.log

Is this what you want?
-- 
Lew Pitcher
"In Skills, We Trust"

[toc] | [prev] | [next] | [standalone]


#7844

FromTodd <Todd@invalid.invalid>
Date2013-04-12 11:47 -0700
Message-ID<kk9kn3$p71$1@dont-email.me>
In reply to#7838
On 04/10/2013 01:20 PM, Lew Pitcher wrote:
> On Wednesday 10 April 2013 14:28, in comp.os.linux.misc,
> Todd@invalid.invalid wrote:
>
>> On 04/10/2013 01:12 AM, Richard Kettlewell wrote:
>>> Lew Pitcher <lpitcher@teksavvy.com> writes:
>>>> Todd@invalid.invalid wrote:
>>>
>>>>> I want to echo debugging statements inside a function
>>>>> the returns its value as an echo.  But I do not want
>>>>> the debugging echo to be part of the return echo.  I want
>>>>> the debugging echo to go to the screen instead.
>>>>>
>>>>> #!/bin/bash
>>>>> abc () {
>>>>>       echo "I want this to go to the screen"
>>>>>       echo "This goes to the return string"
>>>>> }
>>>>> echo "-->$(abc)<--"
>>>>
>>>> To get text to appear on your terminal, no matter where stdout & stderr
>>>> are redirected to, redirect the required output to /dev/tty
>>>
>>> That’s a terrible idea, the process may not have a controlling terminal.
>>> The best places to send debug output are stderr or a logfile.  (See ‘set
>>> -x’ if you want precedent for using stderr.)
>>>
>>
>> Thank you!
>>
>> #!/bin/bash
>> abc () {
>>      echo "I want this to go to the screen" > "/dev/tty"
>>      echo "I want this to go to the screen too" > "/dev/stderr"
>>      echo "This goes to the return string"
>> }
>> echo "-->$(abc)<--"
>>
>>
>> $ ./EchoTest
>> I want this to go to the screen
>> I want this to go to the screen too
>> -->This goes to the return string<--
>
> But...
>    ./EchoTest 2>debug.log
> will only show
>    I want this to go to the screen
>    -->This goes to the return string<--
> and the line
>    I want this to go to the screen too
> will appear in the file ./debug.log
>
> Is this what you want?
>

Hi Lew,

I do not want it to go to a log file, just to the screen
and not be echoed as the function's return string.
The example I posted worked perfectly.

-T

[toc] | [prev] | [next] | [standalone]


#7827

FromTodd <Todd@invalid.invalid>
Date2013-04-09 19:49 -0700
Message-ID<kk2jqs$1s3$1@dont-email.me>
In reply to#7825
On 04/09/2013 07:33 PM, Todd wrote:
> Hi All,
>
> I want to echo debugging statements inside a function
> the returns its value as an echo.  But I do not want
> the debugging echo to be part of the return echo.  I want
> the debugging echo to go to the screen instead.
>
> #!/bin/bash
> abc () {
>     echo "I want this to go to the screen"
>     echo "This goes to the return string"
> }
> echo "-->$(abc)<--"
>
> If you run the above, you will notice everything
> goes to the return variable.
>
> Many thanks,
> -T



Figured it out:

#!/bin/bash
abc () {
    echo "I want this to go to the screen" > "/dev/tty"
    echo "This goes to the return string"
}
echo "-->$(abc)<--"

[toc] | [prev] | [standalone]


Back to top | Article view | comp.os.linux.misc


csiph-web