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


Groups > comp.lang.python > #57396

Re: Reading From stdin After Command Line Redirection

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tundra@tundraware.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'exercise': 0.04; 'broke': 0.09; 'parameter': 0.09; 'pgp': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '23,': 0.16; 'assembler': 0.16; 'eof,': 0.16; 'finney': 0.16; 'subject:Line': 0.16; 'subject:Reading': 0.16; 'sudo': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'wed,': 0.18; 'command': 0.22; '>>>': 0.22; 'input': 0.22; 'example': 0.22; 'shell': 0.22; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'keyboard': 0.24; 'specifies': 0.24; 'specify': 0.24; '(or': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'source': 0.25; 'read,': 0.26; 'asking': 0.27; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'chris': 0.29; 'tim': 0.29; "i'm": 0.30; 'end,': 0.31; 'era': 0.31; 'writes:': 0.31; 'allows': 0.31; 'file': 0.32; 'this.': 0.32; 'probably': 0.32; 'another': 0.32; 'text': 0.33; 'entirely': 0.33; 'sense': 0.34; 'problem': 0.35; 'editor': 0.35; 'there': 0.35; 'passwords': 0.36; 'shows': 0.36; 'two': 0.37; 'ben': 0.38; 'handle': 0.38; 'pm,': 0.38; 'expect': 0.39; 'read': 0.60; 'manually': 0.60; 'reaching': 0.61; "you're": 0.61; 'times': 0.62; 'here': 0.66; 'believe': 0.68; 'default': 0.69; 'goal': 0.75; 'console,': 0.84; 'subject:After': 0.84; '2013,': 0.91; 'achievable': 0.91; 'was:': 0.91; 'to:none': 0.92; 'subject:From': 0.97
Date Wed, 23 Oct 2013 19:09:36 -0500
From Tim Daneliuk <tundra@tundraware.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5
MIME-Version 1.0
Newsgroups comp.lang.python
CC python-list@python.org
Subject Re: Reading From stdin After Command Line Redirection
References <7cdlja-j3j2.ln1@ozzie.tundraware.com> <7wli1jemvg.fsf@benfinney.id.au> <CAPTjJmr6VnTvc0rdPmadp5D39igweUAB1jZG_SgLO4qT9ak0Ug@mail.gmail.com> <1382562096.2967.37713425.4901765B@webmail.messagingengine.com> <mailman.1431.1382566824.18130.python-list@python.org>
In-Reply-To <mailman.1431.1382566824.18130.python-list@python.org>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Greylist Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (ozzie.tundraware.com [192.168.0.1]); Wed, 23 Oct 2013 19:09:43 -0500 (CDT)
X-TundraWare-MailScanner-Information Please contact the ISP for more information
X-TundraWare-MailScanner-ID r9O09hHm093484
X-TundraWare-MailScanner Found to be clean
X-TundraWare-MailScanner-From tundra@tundraware.com
X-Spam-Status No
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Message-ID <mailman.1434.1382574076.18130.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382574076 news.xs4all.nl 15871 [2001:888:2000:d::a6]:48910
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57396

Show key headers only | View raw


On 10/23/2013 05:20 PM, Ben Finney wrote:
> random832@fastmail.us writes:
>
>> On Wed, Oct 23, 2013, at 16:52, Chris Angelico wrote:
>>> There are times when this is correct behaviour - like asking for
>>> passwords (SSH and sudo work like this).
>>
>> Less (or pagers generally, or an interactive text editor that allows
>> creating a file from standard input) would be another example of a
>> program where it makes sense to do this.
>
> You're both describing programs that read the console, which is not what
> the OP was asking for. The OP was asking about re-opening stdin after
> reaching EOF, which is incoherent as far as I understand it.
>
> I'm still waiting for the OP to clarify what they want to do.
>

'Easy there Rainman, the question is entirely coherent,
though it may not be achievable this way.  The goal of the
exercise was:

- Read a file the user specifies via command line redirection
- When the file is fully read, return to reading keyboard
   input with things like raw_input and get_pass which I believe
   use stdin as a source ... probably to avoid having to manually
   cope with ttys and ptys themselves. One of those two functions -
   I don't recall which - was giving me a problem with stdin redirected.

In the end, I broke down and added a command line parameter to
specify which file to read in so that stdin would be unaffected.

Now that I think about it, as I recall from the prehistoric era of writing
lots of assembler and C, if you use shell redirection, stdin shows
up as a handle to the file and there is no way to retrieve/reset it
its default association with the tty/pty.  Since python is layered on
top of this, I expect the same would be the case here as well.



-- 
----------------------------------------------------------------------------
Tim Daneliuk     tundra@tundraware.com
PGP Key:         http://www.tundraware.com/PGP/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 12:25 -0500
  Re: Reading From stdin After Command Line Redirection Chris Angelico <rosuav@gmail.com> - 2013-10-24 07:40 +1100
  Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 07:46 +1100
  Re: Reading From stdin After Command Line Redirection Chris Angelico <rosuav@gmail.com> - 2013-10-24 07:52 +1100
  Re: Reading From stdin After Command Line Redirection random832@fastmail.us - 2013-10-23 17:01 -0400
  Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 09:20 +1100
    Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 19:09 -0500
      Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 14:53 +1100
        Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 23:36 -0500
        Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 23:39 -0500
        Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 15:54 +1100
          Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 06:58 -0500
          Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 06:58 -0500
            Re: Reading From stdin After Command Line Redirection Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-24 13:10 +0100
              Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 08:41 -0500
                Re: Reading From stdin After Command Line Redirection feedthetroll@gmx.de - 2013-10-24 07:36 -0700
                Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 09:43 -0500
              Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-24 08:41 -0500
                Re: Reading From stdin After Command Line Redirection Ethan Furman <ethan@stoneleaf.us> - 2013-10-24 07:30 -0700
      Re: Reading From stdin After Command Line Redirection Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-24 09:14 +0100
      Re: Reading From stdin After Command Line Redirection Ben Finney <ben+python@benfinney.id.au> - 2013-10-24 19:43 +1100
      Re: Reading From stdin After Command Line Redirection Tim Chase <python.list@tim.thechases.com> - 2013-10-24 05:45 -0500
      Re: Reading From stdin After Command Line Redirection Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-10-24 12:33 +0100
      Re: Reading From stdin After Command Line Redirection Ethan Furman <ethan@stoneleaf.us> - 2013-10-24 07:39 -0700
    Re: Reading From stdin After Command Line Redirection Tim Daneliuk <tundra@tundraware.com> - 2013-10-23 19:09 -0500
  Re: Reading From stdin After Command Line Redirection Chris Angelico <rosuav@gmail.com> - 2013-10-24 09:23 +1100

csiph-web