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


Groups > comp.lang.python > #57383

Re: Reading From stdin After Command Line Redirection

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.041
X-Spam-Evidence '*H*': 0.93; '*S*': 0.01; 'expected.': 0.09; 'runs': 0.10; 'itself.': 0.14; '24,': 0.16; '4:25': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Line': 0.16; 'subject:Reading': 0.16; 'tty': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'input': 0.22; 'file.': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; 'open': 0.33; "can't": 0.35; 'usual': 0.35; 'received:google.com': 0.35; 'so,': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'read': 0.60; 'skip:n 10': 0.64; 'subject:After': 0.84; 'on?': 0.91; 'subject:From': 0.97; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=gZ8vGsbPrAzo9bmfs9uYfpgAGQv1cfgcgcKXQmoF2Dg=; b=XeQJFyEgjqzROKi9bse9a21eYXSEt17tlTfF9cVMka2kCHDQ0viiOLXX3+WVWQL65z FZr9Q6igwD5DSinqxhtVO/03LyVW0K3Gqye658vq5QbCubtt1Q+SZEZCJmoyCFzNmhgy OM9ewD3YgU0VIcvlfPro1lfA5obhy/9yZfd9zor0QnDbRnTRk6ctO4c7MYkksJTKI+b5 onRm9+0Ird4b/PcpgryMge37402FY+9z4hGj9XTc0niz/gbG8i+QHMNWOkcD8HsRAASH ku2odrnHotVbf9nwm0VRQDA0dBaHSA4EH9E2mNvYeZYoNTJk5166LqsppqnUyMzUXPVN gfuA==
MIME-Version 1.0
X-Received by 10.68.197.234 with SMTP id ix10mr3438846pbc.185.1382560804612; Wed, 23 Oct 2013 13:40:04 -0700 (PDT)
In-Reply-To <7cdlja-j3j2.ln1@ozzie.tundraware.com>
References <7cdlja-j3j2.ln1@ozzie.tundraware.com>
Date Thu, 24 Oct 2013 07:40:04 +1100
Subject Re: Reading From stdin After Command Line Redirection
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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>
Newsgroups comp.lang.python
Message-ID <mailman.1425.1382560813.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1382560813 news.xs4all.nl 16011 [2001:888:2000:d::a6]:52865
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:57383

Show key headers only | View raw


On Thu, Oct 24, 2013 at 4:25 AM, Tim Daneliuk <tundra@tundraware.com> wrote:
> I have a program that runs like this:
>
>   foo.py <inputfile
>
> I want to reconnect stdin to the tty as usual after 'inputfile'
> has been read so that things like raw_input and getpass
> will work as expected.
>
> So, after I do .... = sys.stdin.readlines(), how to I reopen
> stdin in its nonredirected mode?

You fundamentally can't reopen "stdin", as that will just be your
input file. What you want to do is open the console (TTY) itself. What
platform are you on?

ChrisA

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