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


Groups > comp.lang.python > #33935

Re: how to pass "echo t | " input to subprocess.check_output() method

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <kushal.kumaran@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'argument': 0.04; 'output': 0.04; 'attribute': 0.05; 'svn': 0.05; 'python': 0.09; 'exception,': 0.09; 'p2cread': 0.09; 'res': 0.09; 'subject:method': 0.09; 'throws': 0.09; 'cc:addr:python-list': 0.10; 'library': 0.15; 'passing': 0.15; '"echo': 0.16; 'command,': 0.16; 'stdin': 0.16; 'subject:pass': 0.16; 'url:svn': 0.16; 'string': 0.17; 'wrote:': 0.17; 'input': 0.18; 'sender:addr:gmail.com': 0.18; 'skip:" 30': 0.20; 'all,': 0.21; 'object.': 0.22; 'subversion': 0.22; 'help.': 0.22; 'cc:2**0': 0.23; 'monday,': 0.23; 'cc:no real name:2**0': 0.24; 'command': 0.24; 'pass': 0.25; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'skip:m 30': 0.26; 'this?': 0.28; 'chris': 0.28; 'writes:': 0.29; 'error': 0.30; 'file': 0.32; 'suggestion': 0.32; 'could': 0.32; 'skip:s 30': 0.33; 'received:google.com': 0.34; 'list': 0.35; 'process,': 0.35; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; 'url:org': 0.36; 'method': 0.36; 'communicate': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'think': 0.40; 'url:ip addr': 0.62; 'email addr:gmail.com': 0.63; 'dont': 0.64; 'validate': 0.65; 'url:0': 0.67; 'received:117': 0.75; 'prompt': 0.78; 'message-id:@mx.google.com': 0.81; 'subject:skip:s 20': 0.91; 'to:none': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-type; bh=SD1Op7EIXD4VD/+6mpcCWymhLxWqwayylAMC+SUiegU=; b=b5ICv026+v4Va90gEJec2LIm5o3t9cmGyMJMP55RFf6iRK+Y29ZF5FU9HG6uQinRxT 2Jx8VK22ptMm4RofRDQVFKzxvtEfAU1WlaMe2aBJaIc/3SV2qSm8kpOB7Uy8/AbOsRCH soDTkCPjba1w2ZxIMAW2cQGFmqxqjj/gCjk3XhjiKV6CRjSQNKcYvVoXjTjlLMyGfeYG IllJRQuiAV4kaIJTpafrhv4tRFFmhoGLFFsIZywi0RNxiOjoWWY0ep9SNZ1x6d0dl99g Bn3X4zSlUkxDaCNgvMw8HyPyvRcT4J3Kf08kUGxKudXm3LjaJtUNxAwxqSktfPewIU+b nvmg==
Sender Kushal Kumaran <kushal.kumaran@gmail.com>
From Kushal Kumaran <kushal.kumaran+python@gmail.com>
Cc python-list@python.org
Subject Re: how to pass "echo t | " input to subprocess.check_output() method
In-Reply-To <09f48575-30aa-4d29-8042-2dfcaafe6ca8@googlegroups.com>
References <d8bd2825-3e3a-4b0f-9679-bc86094c4b8c@googlegroups.com> <mailman.286.1353927741.29569.python-list@python.org> <09f48575-30aa-4d29-8042-2dfcaafe6ca8@googlegroups.com>
User-Agent Notmuch/0.14+83~gae459a3 (http://notmuchmail.org) Emacs/24.1.1 (x86_64-pc-linux-gnu)
Date Mon, 26 Nov 2012 18:45:14 +0530
MIME-Version 1.0
Content-Type text/plain
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.289.1353935723.29569.python-list@python.org> (permalink)
Lines 76
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1353935723 news.xs4all.nl 6881 [2001:888:2000:d::a6]:45365
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33935

Show key headers only | View raw


dachakku@gmail.com writes:

> On Monday, 26 November 2012 16:32:22 UTC+5:30, Kushal Kumaran  wrote:
>> dachakku@gmail.com writes:
>> 
>> 
>> 
>> > Hi all,
>> 
>> >
>> 
>> > I want to list the repositories in svn using python. For this i have used below command,
>> 
>> > " res = subprocess.check_output(["svn.exe", "list", "Https://127.0.0.1:443/svn/Repos"], stderr=subprocess.STDOUT) "
>> 
>> >
>> 
>> > but it throws an exception, since it requires an user input to validate certificate,
>> 
>> > " (R)eject, accept (t)emporarily or accept (p)ermanently? "
>> 
>> >
>> 
>> > from Command prompt im able to pass the input while calling the process, and im able to get the output
>> 
>> >
>> 
>> > "echo t | svn list Https://127.0.0.1:443/svn/Repos"
>> 
>> >
>> 
>> > But i dont know how to pass the "echo t | " in subprocess.check_output while calling a process.
>> 
>> > Is there a way to do this?
>> 
>> > Please help.
>> 
>> 
>> 
>> 
>> 
>> You could pass in a stdin argument to subprocess.check_output with a
>> 
>> value of 't\n'.
>> 
>> 
>> 
>> However, you might want to use something like http://pysvn.tigris.org/,
>> 
>> which is a python library for accessing subversion repositories.
>> 
>> 
>> 
>
> Hi Kushal,
>
> I tried passing the value 't\n' to check_output. But I think we cannot pass a string to stdin.
>
> When I tried the below command,
> subprocess.check_output([svn, "list", repos_Url], stdin='t\n', stderr=subprocess.STDOUT)
>
> I got the below error message,
>   File "C:\Python27\lib\subprocess.py", line 786, in _get_handles
>     p2cread = msvcrt.get_osfhandle(stdin.fileno())
> AttributeError: 'str' object has no attribute 'fileno'
>
> could you tell me how to pass the value to stdin..

Follow Chris Rebert's suggestion to use subprocess.Popen and the
communicate method of the Popen object.

Have you taken a look at pysvn?

-- 
regards,
kushal

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


Thread

how to pass "echo t | " input to subprocess.check_output() method dachakku@gmail.com - 2012-11-26 02:36 -0800
  Re: how to pass "echo t | " input to subprocess.check_output() method Duncan Booth <duncan.booth@invalid.invalid> - 2012-11-26 10:52 +0000
    Re: how to pass "echo t | " input to subprocess.check_output() method dachakku@gmail.com - 2012-11-26 04:05 -0800
      Re: how to pass "echo t | " input to subprocess.check_output() method Duncan Booth <duncan.booth@invalid.invalid> - 2012-11-26 12:17 +0000
  Re: how to pass "echo t | " input to subprocess.check_output() method Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2012-11-26 16:32 +0530
    Re: how to pass "echo t | " input to subprocess.check_output() method dachakku@gmail.com - 2012-11-26 04:10 -0800
      Re: how to pass "echo t | " input to subprocess.check_output() method Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2012-11-26 18:45 +0530
    Re: how to pass "echo t | " input to subprocess.check_output() method dachakku@gmail.com - 2012-11-26 04:10 -0800
  Re: how to pass "echo t | " input to subprocess.check_output() method Miki Tebeka <miki.tebeka@gmail.com> - 2012-11-26 07:40 -0800
    Re: how to pass "echo t | " input to subprocess.check_output() method dachakku@gmail.com - 2012-11-28 04:38 -0800
      Re: how to pass "echo t | " input to subprocess.check_output() method Miki Tebeka <miki.tebeka@gmail.com> - 2012-11-28 06:47 -0800

csiph-web