Spawn snmptrap from python


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Spawn snmptrap from python
# 1  
Old 04-09-2013
Spawn snmptrap from python

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

Code:
from subprocess import Popen
Popen(['snmptrap', '-v 2c -c public 192.168.2.162 SNMPv2-SMI::enterprises.3.1.1'])

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

---------- Post updated at 06:32 PM ---------- Previous update was at 03:29 PM ----------

I got this to work and this is the code i used

Code:
import subprocess
from subprocess import Popen, PIPE

path = "-v 2c -c public 192.168.2.162 '' SNMPv2-SMI::enterprises.3.1.1"
Popen(['/opt/csw/bin/snmptrap', '%s' % path], shell=True, stdout=PIPE, stderr=subprocess.STDOUT)

If anyone else has a better way of doing this i will appreciate if you can share with me

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Create a C source and compile inside Python 1.4.0 to 3.7.0 in Python for ALL? platforms...

Hi all... As you know I like making code backwards compatible for as many platforms as possible. This Python script was in fact dedicated for the AMIGA A1200 using Pythons 1.4.0, 1.5.2, 1.6.0, 2.0.1, and 2.4.6 as that is all we have for varying levels of upgrades from a HDD and 4MB FastRam... (1 Reply)
Discussion started by: wisecracker
1 Replies

2. Programming

Help needed to Spawn Shell on Python and Continue Execution

def gob(url): print "\n\t Running gobuster on target." params = " -e -s '307,200,204,301,302' -t 20 -u " + url + " >> /tmp/%s/gobuster.txt" % (ip) os.system("xterm -e bash -c "tail -f /tmp/%/gobuster.txt"") for i in bflist: dirbf = "gobuster -w " + i... (3 Replies)
Discussion started by: alvinoo
3 Replies

3. UNIX for Advanced & Expert Users

Snmptrap command help

Dear all, I have configured the "snmpd.conf" to be able to send traps to a network manager. The file is saved in "/etc/net-snmp/snmp/". Attached is my configuration, which seems to be correct. (The IP address 10.192.4.4 is the trap receiver). Next my aim was to send a test trap to verify... (0 Replies)
Discussion started by: nms
0 Replies

4. Shell Programming and Scripting

**python** unable to read the background color in python

I am working on requirement on spreadsheet in python scripting. I have a spreadsheet containing cell values and with background color. I am able to read the value value but unable to get the background color of that particular cell. Actually my requirement is to read the cell value along... (1 Reply)
Discussion started by: giridhar276
1 Replies

5. UNIX for Advanced & Expert Users

spawn() Vs. fork()

what is diffenrence between spawn and fork ? "fork() system call spawns the processess" what is mean by this sentence. (1 Reply)
Discussion started by: anandgodse
1 Replies

6. Solaris

snmptrap command - Help Please!!

Hi All, I am trying to generate a trap with in the localhost. Please see the attachment for the exact syntax what I am using to generate the traps. However, I am getting the following error. Unknown Object Identifier (Sub-id not found: (top) -> ) Can you please guide me how to use the... (1 Reply)
Discussion started by: ntgobinath
1 Replies

7. Solaris

Spawn Not Found

I need to run the spawn command but when I typed it in, I got "ksh: spawn: not found". So, I downloaded spawn-fcgi but it required to be compiled first. The compile failed when I tried it. I need a copy that's ready to be used. Unix system info: OS: Sun Solaris 2.8 Shell: ksh Does... (4 Replies)
Discussion started by: april
4 Replies

8. IP Networking

snmptrap.conf file

Hi I tried a lot bt could not configure snmptrapd.conf... Can any one tell me the steps or give me the configured snmptrapd.conf file?? Its really important..Plz help me.. Thanx (0 Replies)
Discussion started by: swapna_me
0 Replies

9. UNIX for Dummies Questions & Answers

spawn: not found

Hi, I'm very new to UNIX. I need to FTP a file to a remote host. It happens through a port 2222.I need to automate the process as the SCP command prompts for a password. 1) The regular ftp, tells me that the connection is refused 2) The sftp login@remotehost gives me... (0 Replies)
Discussion started by: sandy.cog
0 Replies
Login or Register to Ask a Question