By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,610 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,610 IT Pros & Developers. It's quick & easy.

spawn snmptrap from python

P: 20
Hi
I am trying to spawn an snmptrap from python but i keep getting the following error

Invalid version specified after -v flag: 2c -c public 192.168.2.162 SNMPv2-SMI::enterprises.3.1.1

here is the python code i am using
Expand|Select|Wrap|Line Numbers
  1. from subprocess import Popen
  2. Popen(['snmptrap', '-v 2c -c public 192.168.2.162 SNMPv2-SMI::enterprises.3.1.1'])
  3.  
When i test the same command from the shell like this it works
snmptrap -v 2c -c public 192.168.2.162 SNMPv2-SMI::enterprises.3.1.1

I tried to close the space between v and 2c so its like this -v2c but i still get the error.

I will appreciate it very much if you can help me correct this or point out to me what i am doing wrong.

Thanks
Kaf
Apr 9 '13 #1
Share this Question
Share on Google+
1 Reply

P: 20
Hi,

I got it to work and this is the code i used
Expand|Select|Wrap|Line Numbers
  1. import subprocess
  2. from subprocess import Popen, PIPE
  3. path = "-v 2c -c public 192.168.2.162 '' SNMPv2-SMI::enterprises.3.1.1"
  4. Popen(['/opt/csw/bin/snmptrap', '%s' % path], shell=True, stdout=PIPE, stderr=subprocess.STDOUT)
  5.  
If someone also has a better way to do it i will appreciate that as well.
Thanks
Apr 9 '13 #2

Post your reply

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