I have a bunch of command line tests that I need to automate. I've
run into too many bugs with the default Win2k command shell, so I need
to either purchase 4NT or handle the logic and output processing with
Python. I'm looking for experiences, comments, problems, etc.
Also, I'm trying to figure out how to use popen(). To say that the
documentation and expamples available for this is sparse would be the
understatment of the century! I know that I want to use popen4() but
what is the difference between os.popen4(), win32pipe.popen4() and
popen2.popen4()(did I miss any?)?
And how, exactly, do I *use* popen4()? I figured out how to use
popen(), but I haven't been too successfull with popen(). A good
example would really come in handy! I have *5* Python books and not
one has an example for anything other than popen()!
Robin L. Siebler
Software Test Engineer
PalmSource
---------------------------------------
Homer Simpson: But every time I learn something new, it pushes out
something old! Remember that time I took a home wine-making course and
forgot how to drive? Marge: That's because you were drunk! Homer
Simpson: And how! 6 1829
On Sun, 2004-09-12 at 18:52, Robin Siebler wrote: And how, exactly, do I *use* popen4()?
import os
command = 'ls -al nonexistent'
fin, fout = os.popen4(command)
# I never futz with stdin.
fin.close()
output = fout.read()
exitCode = fout.close()
if exitCode:
print 'Error running %(command)s:\n%(output)s' % locals()
else:
print 'Success running %(command)s:\n%(output)s' % locals()
This may have minor syntactical errors or typos--since I'm not verifying
it by running it. But mostly, the above pattern should work.
Questions?
// m
Robin Siebler wrote: I have a bunch of command line tests that I need to automate. I've run into too many bugs with the default Win2k command shell, so I need to either purchase 4NT or handle the logic and output processing with Python. I'm looking for experiences, comments, problems, etc.
I'm using 4NT as my interactive shell and it's fine. But as soon as a
script requires something more complex than an IF, I'm doing it in Python.
Also, I'm trying to figure out how to use popen(). To say that the documentation and expamples available for this is sparse would be the understatment of the century! I know that I want to use popen4() but what is the difference between os.popen4(), win32pipe.popen4() and popen2.popen4()(did I miss any?)?
At least in earlier versions of Python, os.popen* didn't worked when the
script was being called from a service or a GUI program, as such
programs had no 'console' and therefor no stdin and stdout.
win32pipe.popen* fixed that.
Daniel
At the risk of being labeled a heretic, I'm gonna suggest cygwin. In
particular, the bash shell is really well suited for running
"automated" CLI tests. Be aware though that bash syntax is really
cryptic and if you don't use it a lot, you'll find yourself thumbing
through the manual quiet a bit.
If you do decide to do bash, do a google on "advanced bash tutorial".
That ought to point you to a really nice tutorial.
HTH,
jw
On 12 Sep 2004 16:52:51 -0700, Robin Siebler
<ro***********@palmsource.com> wrote: I have a bunch of command line tests that I need to automate. I've run into too many bugs with the default Win2k command shell, so I need to either purchase 4NT or handle the logic and output processing with Python. I'm looking for experiences, comments, problems, etc.
Also, I'm trying to figure out how to use popen(). To say that the documentation and expamples available for this is sparse would be the understatment of the century! I know that I want to use popen4() but what is the difference between os.popen4(), win32pipe.popen4() and popen2.popen4()(did I miss any?)?
And how, exactly, do I *use* popen4()? I figured out how to use popen(), but I haven't been too successfull with popen(). A good example would really come in handy! I have *5* Python books and not one has an example for anything other than popen()!
Robin L. Siebler Software Test Engineer PalmSource --------------------------------------- Homer Simpson: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive? Marge: That's because you were drunk! Homer Simpson: And how! -- http://mail.python.org/mailman/listinfo/python-list
* Jaime Wyant (2004-09-13 14:56 +0200) At the risk of being labeled a heretic, I'm gonna suggest cygwin. In particular, the bash shell is really well suited for running "automated" CLI tests. Be aware though that bash syntax is really cryptic [...]
Cryptic compared to Python syntax but a lot more readable than Windows
cmd.exe syntax.
If you do decide to do bash, do a google on "advanced bash tutorial". That ought to point you to a really nice tutorial.
* Advanced Bash-Scripting Guide http://www.tldp.org/LDP/abs/html/index.html http://personal.riverusers.com/~theg...de-2.8.tar.bz2 http://www.tldp.org/LDP/abs/abs-guide.pdf
I'd consider IPython (state-of-the-art replacement for basic Python
CLI) in "shell mode" ("This profile turns IPython into a lightweight
system shell with python syntax").
Thorsten
> I'd consider IPython (state-of-the-art replacement for basic Python CLI) in "shell mode" ("This profile turns IPython into a lightweight system shell with python syntax").
I tried IPython some time ago, but it didn't quite work properly on
Windows. Has that been fixed?
In article <95*************************@posting.google.com> ,
Robin Siebler <ro***********@palmsource.com> wrote: I have a bunch of command line tests that I need to automate. I've run into too many bugs with the default Win2k command shell, so I need to either purchase 4NT or handle the logic and output processing with Python. I'm looking for experiences, comments, problems, etc.
While I haven't done any Windows shell programming for years, I used to
be a heavy 4DOS user (and I think I actually purchased 4NT at one
point). These days, I wouldn't even consider 4NT for anything serious.
--
Aahz (aa**@pythoncraft.com) <*> http://www.pythoncraft.com/
"A foolish consistency is the hobgoblin of little minds, adored by little
statesmen and philosophers and divines." --Ralph Waldo Emerson This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Alexander Schmolck |
last post by:
Two smallish things that have been bugging me; I'm not sure whether they're
actually broken or not, but anyway here it goes:
1. ``os.system`` (and co): Shouldn't ``os.system``'s signature really...
|
by: Xah Lee |
last post by:
Python Doc Problem Example: os.system
Xah Lee, 2005-09
today i'm trying to use Python to call shell commands. e.g. in Perl
something like
output=qx(ls)
in Python i quickly located the...
|
by: diffuser78 |
last post by:
I want to write a python program and call OS specific commands in it.
So basically, instead of typing in on the command line argument I want
to have it in a python program and let it do the action....
|
by: Kurt B. Kaiser |
last post by:
Patch / Bug Summary
___________________
Patches : 413 open ( +1) / 3407 closed (+10) / 3820 total (+11)
Bugs : 897 open ( -3) / 6167 closed (+18) / 7064 total (+15)
RFE : 234 open...
|
by: Jonathan Fine |
last post by:
Hello
My problem is that I want a Python 2.4 module on
a server that is running Python 2.3. I definitely
want to use the 2.4 module, and I don't want to
require the server to move to Python...
|
by: Joe Salmeri |
last post by:
I just upgraded from Python 2.4.2 to Python 2.5.1 and have found some
unexpected behavior that appears to be a bug in the os.stat module.
My OS is Windows XP SP2 + all updates.
I have several...
|
by: mclaugb |
last post by:
Hello ALl,
I have a compiled program "conv.exe" that works as follows:
-----------------------------
Please selection from the following options. press "h" for help, "p" for
print, "r" for...
|
by: Aidan |
last post by:
Hi,
I'm having a bit of trouble with a python script I wrote, though I'm not
sure if it's related directly to python, or one of the other software
packages...
The situation is that I'm trying...
|
by: bruce |
last post by:
hi...
can someone point me to where/how i would go about calling a ruby app from a
python app, and having the python app being able to get a returned value
from the ruby script.
something...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |