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

Python / Shell script output (log) capturing

2
Hi,

I have a Python script to upload the Invoice data which is in .csv file to OTM (GLOG) system. I'm running this script using the command(given below) using a shell script and capturing the output to a file (which we are refering as a log).


python TestInvoiceTransform.py -glUserGid <user> -glPassword <password> -inputFileName TestInvoice.csv -hostname <host url> -mailto <mail id> -smtphost amermsx.med.ge.com > test.log

The output is going to the file fine when the transmission is correct. But when the transmission fails, the actual error message is not going to the log file. I'm able to see this error message on the console, but not getting in my log file.

Can any one help me in this regard.

Any help on this is greatly appreciated.

Thanks much,
Jithender
Feb 4 '08 #1
2 2940
This sentence should achieve that:
Expand|Select|Wrap|Line Numbers
  1. sys.stderr = sys.stdout

Expand|Select|Wrap|Line Numbers
  1. stdin 
  2. stdout
  3. stderr
  4. File objects corresponding to the interpreter's standard input, output and error streams. stdin is used for all interpreter input except for scripts but including calls to input() and raw_input(). stdout is used for the output of print and expression statements and for the prompts of input() and raw_input(). The interpreter's own prompts and (almost all of) its error messages go to stderr. stdout and stderr needn't be built-in file objects: any object is acceptable as long as it has a write() method that takes a string argument. (Changing these objects doesn't affect the standard I/O streams of processes executed by os.popen(), os.system() or the exec*() family of functions in the os module.) 
Feb 4 '08 #2
jallam
2
That was great...
It worked...
Thanks much
Feb 5 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Matthew Thorley | last post by:
My friend sent me an email asking this: > I'm attemtping to decide which scripting language I should master and > was wondering if it's possible to do > these unixy awkish commands in python:...
4
by: cepl | last post by:
Is there anything like script(1) for python interactive sessions. From script(1) manpage: Script makes a typescript of everything printed on your terminal. It is useful for students who need a...
10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
8
by: Harlin Seritt | last post by:
I have a remote linux server where I can only access it via ssh. I have a script that I need to have run all the time. I run like so: python script.py & It runs fine. When I log off ssh I...
4
by: vagrantbrad | last post by:
I'm using python 2.4 running on Fedora Core 4. I have written a python program called ipscan.py that checks the external ip address of my cable internet connection, and on change, will update the...
4
by: Layne Meier | last post by:
I'm having a bit of a problem trying to install Python on a Solaris 10 system. I didn't have this kind of problem when trying to install it on Solaris 8. Has anyone else experienced this...
10
by: A.M | last post by:
Hi, I am having difficulty with shell scripting in Python. I use the following command to run a DOS command and put the return value in a Python variable:
16
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....
3
by: koutoo | last post by:
Is it possible to display messages in the python shell? I want to display error messages based on parameters in my scripts to the users. Is there another way to display messages other than log...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.