How are arguments passed to a bash script?
I am using SNMP traps to pass information via snmp from a module on one system to a module on another system. Specifically, I am using SNMPv2 Notify messages, as described on this page:
http://www.net-snmp.org/wiki/index.p...ring_snmptrapd Now, for reasons that are not at all clear to me, snmptrapd expects that the command that it invokes when it processes a trap will be a shell script. I do not wish to use a shell script; I want to have snmptrapd invoke a dedicated C program that I will provide. This C program will accept the data that is being sent via the trap, and will forward that data via some IPC mechanism (I haven't decided yet...probably a TCP socket) to its ultimate destination. I am correctly building the SNMP trap message in my C module, and sending it. The snmptrapd is properly processing it and invoking an appropriate command. When that command is the demo handler script as described on the net-snmp page (and reproduced here), everything works as expected and the output is correct (a text file in /tmp, for now). When I replace that script with a dedicated C program, the result is not as desired; I am not picking up the trap information although the program is being invoked. Specifically, here is the demo trap handler script I am using, from the net-snmp site: Code:
#!/bin/sh Code:
#include <stdio.h> Code:
executing script Code:
arg count is So, the problem here is quite obviously that I do not know where to pick up the argument list that is passed to a shell script when it is invoked. Could anyone here tell me where that argument list is kept? Perhaps a code fragment that will pick it up? |
I got it.
An fread to stdin picks everything up. Sometimes, though, you have to go through this kind of exercise (post all the details) before the answer becomes obvious. In this case, it was a mention in a manpage about bash reading stdin that got me to recognize that I simply needed to read stdin. |
All times are GMT -5. The time now is 05:13 AM. |