Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > how to pass "echo t | " input to subprocess.check_output() method

Reply
Thread Tools

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

 
 
dachakku@gmail.com
Guest
Posts: n/a
 
      11-26-2012
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.
 
Reply With Quote
 
 
 
 
Kushal Kumaran
Guest
Posts: n/a
 
      11-26-2012
http://www.velocityreviews.com/forums/(E-Mail Removed) 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

 
Reply With Quote
 
 
 
 
dachakku@gmail.com
Guest
Posts: n/a
 
      11-26-2012
On Monday, 26 November 2012 16:22:42 UTC+5:30, Duncan Booth wrote:
> (E-Mail Removed) 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.
 
Reply With Quote
 
dachakku@gmail.com
Guest
Posts: n/a
 
      11-26-2012
On Monday, 26 November 2012 16:32:22 UTC+5:30, Kushal Kumaran wrote:
> (E-Mail Removed) 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..
 
Reply With Quote
 
dachakku@gmail.com
Guest
Posts: n/a
 
      11-26-2012
On Monday, 26 November 2012 16:32:22 UTC+5:30, Kushal Kumaran wrote:
> (E-Mail Removed) 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..
 
Reply With Quote
 
Kushal Kumaran
Guest
Posts: n/a
 
      11-26-2012
(E-Mail Removed) writes:

> On Monday, 26 November 2012 16:32:22 UTC+5:30, Kushal Kumaran wrote:
>> (E-Mail Removed) 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
 
Reply With Quote
 
Miki Tebeka
Guest
Posts: n/a
 
      11-26-2012
> 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.
 
Reply With Quote
 
dachakku@gmail.com
Guest
Posts: n/a
 
      11-28-2012
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...
 
Reply With Quote
 
Miki Tebeka
Guest
Posts: n/a
 
      11-28-2012
On Wednesday, November 28, 2012 4:38:35 AM UTC-8, (E-Mail Removed) wrote:
> Thanks.. Creating two subprocesses worked for me. I did the code as below,

Glad it worked.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: Variable Input on procedure - pass by value or pass by reference? Reuven VHDL 0 03-19-2009 07:21 PM
Re: Variable Input on procedure - pass by value or pass by reference? Tricky VHDL 0 03-19-2009 03:59 PM
Variable Input on procedure - pass by value or pass by reference? Tricky VHDL 0 03-19-2009 03:58 PM
can i pass data with input text instead of input hidden? Walter ASP General 6 09-17-2004 11:16 AM



Advertisments