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


Groups > comp.lang.python > #33927 > unrolled thread

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

Started bydachakku@gmail.com
First post2012-11-26 02:36 -0800
Last post2012-11-28 06:47 -0800
Articles 11 — 4 participants

Back to article view | Back to comp.lang.python


Contents

  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

#33927 — how to pass "echo t | " input to subprocess.check_output() method

Fromdachakku@gmail.com
Date2012-11-26 02:36 -0800
Subjecthow to pass "echo t | " input to subprocess.check_output() method
Message-ID<d8bd2825-3e3a-4b0f-9679-bc86094c4b8c@googlegroups.com>
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.

[toc] | [next] | [standalone]


#33928

FromDuncan Booth <duncan.booth@invalid.invalid>
Date2012-11-26 10:52 +0000
Message-ID<XnsA1176EA328251duncanbooth@127.0.0.1>
In reply to#33927
dachakku@gmail.com wrote:

> 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.
> 

Run svn once manually as the same user that is running your script then 
when you get the prompt verify that it is indeed the certificate and 
accept it permanently. That will allow your script to work proviuded the 
certificate doesn't change.

Also, change the command you run to include the --non-interactive 
command line option so that if the certificate ever does change in the 
future the command will fail rather than prompting.

Alternatively use --non-interactive --trust-server-cert to just accept 
any old server regardless what certificate it uses, but be aware that 
this impacts security.

-- 
Duncan Booth http://kupuguy.blogspot.com

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


#33930

Fromdachakku@gmail.com
Date2012-11-26 04:05 -0800
Message-ID<09cde9f8-9c69-4613-a31a-9586bf684d3a@googlegroups.com>
In reply to#33928
On Monday, 26 November 2012 16:22:42 UTC+5:30, Duncan Booth  wrote:
> dachakku@gmail.com wrote:
> 
> 
> 
> > 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.
> 
> > 
> 
> 
> 
> Run svn once manually as the same user that is running your script then 
> 
> when you get the prompt verify that it is indeed the certificate and 
> 
> accept it permanently. That will allow your script to work proviuded the 
> 
> certificate doesn't change.
> 
> 
> 
> Also, change the command you run to include the --non-interactive 
> 
> command line option so that if the certificate ever does change in the 
> 
> future the command will fail rather than prompting.
> 
> 
> 
> Alternatively use --non-interactive --trust-server-cert to just accept 
> 
> any old server regardless what certificate it uses, but be aware that 
> 
> this impacts security.
> 
> 
> 
> -- 
> 
> Duncan Booth http://kupuguy.blogspot.com

Hi Duncan,

I tried using --non-interactive --trust-server-cert, but the call fails with error message,
svn: E175002: OPTIONS of 'https://127.0.0.1/svn/Repos': Server certificate verification failed: certificate issued for a different hostname, issuer is not trusted (https://127.0.0.1)

that's why I want to pass an input to accept the certificate (t)emporarily or (p)ermanently.

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


#33933

FromDuncan Booth <duncan.booth@invalid.invalid>
Date2012-11-26 12:17 +0000
Message-ID<XnsA1177C275B40Fduncanbooth@127.0.0.1>
In reply to#33930
dachakku@gmail.com wrote:

> Hi Duncan,
> 
> I tried using --non-interactive --trust-server-cert, but the call
> fails with error message, svn: E175002: OPTIONS of
> 'https://127.0.0.1/svn/Repos': Server certificate verification failed:
> certificate issued for a different hostname, issuer is not trusted
> (https://127.0.0.1) 
> 
> that's why I want to pass an input to accept the certificate
> (t)emporarily or (p)ermanently. 
> 

I think you probably need to configure your web server so the certificate 
is valid for whichever hostname you use (if the svn server is also used by 
other machines then connect to it using the external hostname rather than 
localhost).

Or just use http:// configured to allow access through localhost only.

-- 
Duncan Booth http://kupuguy.blogspot.com

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


#33929

FromKushal Kumaran <kushal.kumaran+python@gmail.com>
Date2012-11-26 16:32 +0530
Message-ID<mailman.286.1353927741.29569.python-list@python.org>
In reply to#33927
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.

-- 
regards,
kushal

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


#33931

Fromdachakku@gmail.com
Date2012-11-26 04:10 -0800
Message-ID<09f48575-30aa-4d29-8042-2dfcaafe6ca8@googlegroups.com>
In reply to#33929
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.
> 
> 
> 
> -- 
> 
> regards,
> 
> kushal

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..

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


#33935

FromKushal Kumaran <kushal.kumaran+python@gmail.com>
Date2012-11-26 18:45 +0530
Message-ID<mailman.289.1353935723.29569.python-list@python.org>
In reply to#33931
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

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


#33932

Fromdachakku@gmail.com
Date2012-11-26 04:10 -0800
Message-ID<mailman.288.1353931866.29569.python-list@python.org>
In reply to#33929
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.
> 
> 
> 
> -- 
> 
> regards,
> 
> kushal

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..

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


#33937

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2012-11-26 07:40 -0800
Message-ID<d98470f2-6f8f-4b65-a129-540be773f7e4@googlegroups.com>
In reply to#33927
> But i dont know how to pass the "echo t | " in subprocess.check_output while calling a process.
You need to create two subprocess and connect the stdout of the first to the stdin of the 2'nd.

See http://pythonwise.blogspot.com/2008/08/pipe.html for a possible solution.

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


#34018

Fromdachakku@gmail.com
Date2012-11-28 04:38 -0800
Message-ID<67078169-6b32-4fca-8a53-f504998087a4@googlegroups.com>
In reply to#33937
On Monday, 26 November 2012 21:10:02 UTC+5:30, Miki Tebeka  wrote:
> > But i dont know how to pass the "echo t | " in subprocess.check_output while calling a process.
> 
> You need to create two subprocess and connect the stdout of the first to the stdin of the 2'nd.
> 
> 
> 
> See http://pythonwise.blogspot.com/2008/08/pipe.html for a possible solution.

Hi Miki,
Thanks.. Creating two subprocesses worked for me. I did the code as below,

p = subprocess.Popen("echo t |", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
p1 = subprocess.Popen(["svn.exe", "list", "Https://127.0.0.1:443/svn/Repos"], shell=True, stdin=p.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
output = p1[0]

Thanks again... :)

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


#34024

FromMiki Tebeka <miki.tebeka@gmail.com>
Date2012-11-28 06:47 -0800
Message-ID<106fc449-5ffd-44b2-b216-b425262e03e6@googlegroups.com>
In reply to#34018
On Wednesday, November 28, 2012 4:38:35 AM UTC-8, dach...@gmail.com wrote:
> Thanks.. Creating two subprocesses worked for me. I did the code as below,
Glad it worked.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web