in reply to How do I Determine if my script is being piped to?

Have you tried -p STDIN?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: How do I Determine if my script is being piped to?

Replies are listed 'Best First'.
Re^2: How do I Determine if my script is being piped to?
by netguy (Novice) on Nov 21, 2013 at 00:53 UTC

    Just tested -p and looks like that's just the opposite of -t. At least in my case that is the behavior.

    I guess my question was more on the side of I didn't know what to search for. The -p and -t operators can accomplish what I need. It's almost silly that the solution was staring me in the face and I didn't know it. During my many searches, I came across -p a couple times and maybe -t, but didn't have the instinct to look them up.

    Thanks again for the help.

Re^2: How do I Determine if my script is being piped to?
by Discipulus (Canon) on Nov 21, 2013 at 09:21 UTC
    ooh thanks BrowserUk never eard of -p operator, or may be forgotten it long time ago.
    Due to my ignorance i wonder if -p -t are one the opposite of the other: in the docs -p is just mentioned and, albeit self explanatory, not described. There are cases where -t does not suffice, are also cases where -p does not suffice? edge cases?
    My test:
    perl -e " print -t STDIN ? qq(STDIN has tty) : qq(NO tty associated);p +rint ' - '; print -p STDIN ? qq(STDIN is a pipe or a named pipe) : qq +(NOT a pipe)" #out #STDIN has tty - NOT a pipe hostname | perl -e " print -t STDIN ? qq(STDIN has tty) : qq(NO tty as +sociated);print ' - '; print -p STDIN ? qq(STDIN is a pipe or a named + pipe) : qq(NOT a pipe)" #out #NO tty associated - STDIN is a pipe or anamed pipe
    thanks
    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      There are cases where -t does not suffice, are also cases where -p does not suffice? edge cases?

      Search the stat() docs for S_IFIFO.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.