novice20 17 Junior Poster

hi all..


am working with python 2.4.1 n have pysnmp 4.1.14a installed..
the statement
from pysnmp.entity.rfc3413.oneliner import cmdgen
gives me the following error:

ImportError: No module named pysnmp.entity.rfc3413.oneliner

can anyone pls give me the reason? eagerly awaiting any response.

Thanx in advance

novice20 17 Junior Poster

can anyone pls illustrate the use of snmpget in python, along with the explanation??

thanx in advance:)

novice20 17 Junior Poster

Thanks for the reply..the first method works great, but what if I want to handle the exceptions in the main script that is not handled in called script??

i.e., if I call script.py from main.py, and I want to handle unhandled exceptions of script.py in main.py. What can be done?

There are a few ways:

(1) import os
os.system("external_script.py")

(2) import os
out = os.popen("external_script.py")
output = out.readlines() # can get output of script

(3) import the script if the external script contains function or class
that you want to use.


Practice Python Online
http://pyschools.com

novice20 17 Junior Poster

could anyone please help me regarding how to add a newline character to the log file created using logging module.

All the output is dumped onto a single line, which makes it unreadable. I s there any way to make the log file legible?

novice20 17 Junior Poster

could anyone help me regarding calling different python scripts from within a main script.How can this be acheived?

Thanks in advance

novice20 17 Junior Poster

f=open("myfile.txt","w")
os.dup2(sys.stdout,f)
os.dup2(sys.stderr,f)

is the above right method for duplicating file descriptors? that is duplicating output to both console and log file?

novice20 17 Junior Poster

One more doubt..is it possible to duplicate the output using 'loggigng' i.e, both display it on console n redirect it to log file?

pls bear with me if u feel my queries r silly:) am quite new to python

novice20 17 Junior Poster

Thanx a lot for ur reply...but, could u pls explain me what is that "adjusting of scripts?"

You can create a script, wich loads your scripts with subprocess, and then you can redirect the output, like this you won't need to adjust the scripts.

More than that, you can write a module or use logging as told, but for that you must adjust your acripts to.

Cheers and Happy coding


Cheers and Happy coding

novice20 17 Junior Poster

To redefine my query, how to write a generic script, which is invoked by all other scripts, which helps in keeping a log of output from all the scripts?

novice20 17 Junior Poster

Thanx for the replies..I want all the output to text file meanwhile being displayed on console..am using LINUX. I am supposed to write a main script, which in turn invokes many other scripts n the output from all the scripts should be logged.How can this be done?

novice20 17 Junior Poster

I am new to python n developing scripts as a part of my project.I need help regarding HOW THE OUTPUT OF THE SCRIPT CAN BE REDIRECTED TO A TEXT FILE(FOR MAINTAINING ERROR LOG), WHILE ALSO PRINTING IT ON CONSOLE??

Thanks for all the help in advance and I am looking forward for it