473,585 Members | 2,657 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1656
In article <40************ ***********@new sreader.visi.co m>,
PWR <cy***@frontier net.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_PROGR AM.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_PROGRA M.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.getsta tusoutput not being understandable to Windows.

On windows, I usually use the following:

def getoutput(cmdli ne):
fil = os.popen(cmdlin e, '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
2515
by: Erik Andersson | last post by:
Hi! <? class Foo { function getMessage() { return "foo"; } } class Bar { function getFoo() {
3
11619
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 this because the external script can read the database and can emit xml that i want to use. index.php (or whatever) wants to grab this xml and pass...
4
1351
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 outputs it in Pig Latin. I want my Python script to call the program, pipe some input into it and read the output: english = "hello world"...
1
2018
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 still getting the hang of javascript, and I've searched the web, but
4
2470
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 the xml is fully loaded. The link to the xml file is valid. my code is as follows... xmlf =...
1
1906
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 looks like this: var constants = document.createElement("script"); constants.src = REL_PATH + "extensions_demo/js/constants_" + MY_LANGUAGE + ".js";...
1
1513
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
5312
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: 1>make_buildinfo.obj : error LNK2019: unresolved external symbol __imp__RegQueryValueExA@24 referenced in function _make_buildinfo2 Ask on...
0
7908
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8336
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2343
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.