473,400 Members | 2,163 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,400 software developers and data experts.

Accessing external file output from script?

PWR
Platform: Windows
Python: 2.3
Python Skill: Reading, Learning, but still newbie.

Mission: My mission is writing a script that is triggered from my mail
server. The script will execute and download a file. The email that
triggered the message has a file size which is compared to the
downloaded file to make sure the bytes match. Once that is accomplished
there is a small program (.exe) that I can run against the file. The
..exe has two outputs...

If the file that was downloaded is intact is returns nothing

If the file is damaged or not correct it returned ERROR_XXX

Those are the only things it will return.

Is there a way to call this program to run from my script and then
parse? the output to see if either state is returned?

The good news is the script runs and does everything but the external
file check (woo) so I am making progress.
-P.
--
c y r a t (a_t) f r o n t i e r n e t (d o t) n e t

Jul 18 '05 #1
2 1643
In article <40***********************@newsreader.visi.com>,
PWR <cy***@frontiernet.net> wrote:
Platform: Windows
Python: 2.3
Python Skill: Reading, Learning, but still newbie.

Mission: My mission is writing a script that is triggered from my mail
server. The script will execute and download a file. The email that
triggered the message has a file size which is compared to the
downloaded file to make sure the bytes match. Once that is accomplished
there is a small program (.exe) that I can run against the file. The
.exe has two outputs...

If the file that was downloaded is intact is returns nothing

If the file is damaged or not correct it returned ERROR_XXX

Those are the only things it will return.

Is there a way to call this program to run from my script and then
parse? the output to see if either state is returned?

The good news is the script runs and does everything but the external
file check (woo) so I am making progress.

Jul 18 '05 #2
> I believe you are saying that you want to know a Python idiom
for launching an external application (MY_SMALL_PROGRAM.exe?),
perhaps with a command-line argument or two, and collect its
result back into a Python variable for subsequent processing.
Is that correct? What does "return" mean to you in this con-
text? Are you saying that MY_SMALL_PROGRAM.exe puts specific
output such as "ERROR_XXX" to its stdout (or stderr?), or is
your focus on the process's exit status?

I suspect you'll end up reading <URL:
http://python.org/doc/current/lib/module-popen2.html >.

Question for the audience: what are the impediments to making
<URL: http://python.org/doc/current/lib/module-commands.html >
available for Windows?


I don't know if there are many, other than the format of the os.popen
call of commands.getstatusoutput not being understandable to Windows.

On windows, I usually use the following:

def getoutput(cmdline):
fil = os.popen(cmdline, 'r')
output = fil.read()
fil.close()
return output

But I don't bother with the status output.

The reasons may be related to the windows specifics required for
os.popen5 that should be included in some future Python release.

- Josiah
Jul 18 '05 #3

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

Similar topics

2
by: Erik Andersson | last post by:
Hi! <? class Foo { function getMessage() { return "foo"; } } class Bar { function getFoo() {
3
by: konsu | last post by:
hello, when a web request comes to my index.php, i would like index.php to execute a php script stored in an external file and capture the external script's output to a variable. i am doing...
4
by: Paul Rubin | last post by:
Anyone know if there's code around to filter text through an external process? Sort of like the Emacs "filter-region" command. For example, say I have a program that reads input in English and...
1
by: John B. | last post by:
In an effort to turn a little more a module with my pages, I would like to turn my internal javascripts into an external javascript files to supply the information onto a web page. I...
4
by: Brian Quigley | last post by:
Hi, i am trying to write a script to parse an external xml file, but am having problems... the problem i think has to do with me trying to do Response.Write(xmlDoc.transformNode(xslDoc)) before...
1
by: dnn | last post by:
How can I access dynamically loaded variables? I am trying to load an external javascript file dynamically and then access its variables. The script is loaded by the onload handler. The code...
1
by: homesick123 | last post by:
Hi I am very new to perl.I want to write a script which will access the directories and their sub-directories.For eg. -default ----main -------dir1 ---------- ------------ ...
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.