473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

win32- system call - getting results back into python

Hey everyone,

I'm trying to call a system command "svnlook log \arms" from within
python and process the results. However I'm having trouble getting the
results of the command back into python. I'm using windows if that
matters.

Here's what I have so far:

os.system("svnlook") #works but doesn't give me the output from
svnlook, just the status

commands.gettegetstatusoutput("svnlook") only works in unix?

Here's my final code which really <should> work:

pipe=os.popen("svnlook log \arms") #works from console
text=pipe.read()
print text
I get blank


However this works fine and gives me many lines of output:
pipe=os.popen("dir")
text=pipe.read()
print text

Any idea what I'm doing wrong? When I call my command from the command
prompt in windows I get a line of text. By the way, I tried posting
this on the subversion group but I'm thinking maybe it's a python
question, or both?

Thanks,

Greg

Jul 19 '05 #1
2 2280
You wil have to use r"svnlook log \arms") or "svnlook log \\arms") to
escape the "\".

Popen usually return a file-like object, so you maye to use file
methods like .read()

ex:
d = os.popen('dir /b')
print d.read()

Jul 19 '05 #2
gr********@gmail.com wrote:
I'm trying to call a system command "svnlook log \arms" from within
python and process the results. However I'm having trouble getting the
results of the command back into python. I'm using windows if that
matters.


As "runes" pointed out, you are getting caught by the \a escape sequence.

A better solution in this particular case is to see that the SVN
utilities all understand forward slashes just fine, so you can use
"svnlook log /arms" and it should work.

Note that there is also a Python library that wraps the SVN interface so
you could also skip the direct calls to svnlook and do this with Python
calls instead. Google for "pysvn" for more.

-Peter
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Scaramouche | last post by:
is there an equivalent to unixs' ps command in perl? i was writing some win32 scripts and i needed a listing of specific processes. i could perhaps grep through a list of running processes but how...
1
by: RL | last post by:
Hi all, I am new and am lost with Win32::Process stuff. I want on perl script to start a process, then another perl script to terminate the same process. I can start a process using......
5
by: Bryan Parkoff | last post by:
Please provide me the information when it is not in the correct newsgroups. I have been using C and C++ language for a long time when it is time for me to learn Win32 API functions that they can...
6
by: Pawel | last post by:
Ary you know tools to convert MSIL code (Assembly) to Win32 (not Just In Time)?
2
by: Tony Johansson | last post by:
Hello!! When you for example use C++.net environment for develop an GUI application does this mean that you doesn't use win32 API as much as when you had visual studio 6.0 because of the large...
8
by: Tony Johansson | last post by:
Hello! I just wonder what the difference is between a native win32-app and MFC. What I know is that you can use Win32 API in both cases. I think an MFC application is connected with a GUI...
3
by: sandycat05 | last post by:
Hello all, I am a new Perl programmer. Below is the beginnings of a code that I am using to manipulate an Excel spreadsheet via Perl using win32::OLE. However, what I'd like to do is the following:...
3
by: jbenezech | last post by:
Hi All, I have a perl script which starts a java process using Win32::Process. Here is the code to start the java proces: Win32::Process::Create($ProcessObj, ...
1
by: mohanprasadgutta | last post by:
Hi, I need help to open a password protected excel file in perl using Win32:OLE. when I tried to open file in normal way at the time of program execution it is prompting me to enter password. I am...
6
by: Perl Beginner | last post by:
Good morning all, I had to reinstall Perl (ActivePerl 5.10.0 Build 1004) on my computer (Windows XP), the install went fine. however, I'm having issues loading Win32-GuiTest using the repository in...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.