Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 26th, 2012, 04:29 AM
dachakku dachakku is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 dachakku User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 20 sec
Reputation Power: 0
How to pass `echo t | ` as arg in `subprocess.check_output`

Hi,

I have called an exe using subprocess.check_output from my python script.

Code:
res = subprocess.check_output(["svn.exe", "list", "Https://127.0.0.1:443/svn/Repos"], stderr=subprocess.STDOUT)


when the script is executed, it would ask user to enter an input key,

Code:
(R)eject, accept (t)emporarily or accept (p)ermanently?


In Command prompt, i am able to pass the input key to the process while calling itself with below command and i am able to get the output:

Code:
echo t | svn.exe list Https://127.0.0.1:443/svn/Repos


from python to call the exe, i am not able to pass the "echo t | " in subprocess.check_output function.

Is there any way to do this.
Please help.

Reply With Quote
  #2  
Old November 26th, 2012, 10:18 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,359 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 3 Days 9 h 43 m 13 sec
Reputation Power: 383
use shell=True
unix example:
subprocess.check_output("echo t | cat", shell=True,stderr=subprocess.STDOUT)
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #3  
Old November 28th, 2012, 06:36 AM
dachakku dachakku is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 dachakku User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 20 sec
Reputation Power: 0
Quote:
Originally Posted by b49P23TIvg
use shell=True
unix example:
subprocess.check_output("echo t | cat", shell=True,stderr=subprocess.STDOUT)


Hi b49P23TIvg,
Thanks for your input. but that doesnt work for me.
I resolved the issue by using two subprocesses, and providing the output of the first process as input to second process.

Code:
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]

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > How to pass `echo t | ` as arg in `subprocess.check_output`

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap