Don Cohen wrote:
Andre wrote:
Here's a demo of the problem.  I enter these commands:
 snmptrapd
 snmptrap -v 1 -c private 10.0.0.1 TRAP-TEST-MIB::asante 10.0.0.1 6
  117 '' SNMPv2-MIB::sysLocation.0 s $'XXX' .1.2.3.4 i 1234
 snmptrap -v 1 -c private 10.0.0.1 TRAP-TEST-MIB::asante 10.0.0.1 6
  117 '' SNMPv2-MIB::sysLocation.0 s $'XXX, iso.2.3.4 = INTEGER: 1234'

<snip>

The output is the same.  The input is different.  I should be able to
determine the input from the output. This problem would be solved if the string were printed with quoting, e.g., the first output should say ... STRING: "XXX"
and the second
 ... STRING: "XXX, iso.2.3.4 = INTEGER: 1234"
and if the string contains any "'s or \'s they could be quoted with a
preceding \.

The single quote is removed by the shell (assuming you using *nix). You will need to put in the backslashes yourself so it is passed as one argument:

snmptrap -v 1 -c private 10.0.0.1 TRAP-TEST-MIB::asante 10.0.0.1 6117 '' SNMPv2-MIB::sysLocation.0 s $\'XXX, iso.2.3.4 = INTEGER: 1234\'

Save this as test.c and compile this with 'gcc test.c':

int main(int argc, char *argv[]) {
  int i;
  for (i=0; i<argc; i++) {
    printf("argv: %s\n",argv[i]);
  }
  return 0;
}

Here is my input and output:

$ ./a.out one '' three 'four' \'five\'
argv: ./a.out
argv: one
argv:
argv: three
argv: four
argv: 'five'

As you can see the '' makes it an empty argument, 'four' is seen as just four, and \'five\' is seen as 'five'.

Running the above from Windows under a MinGW MSYS shell gives the same result. Running under a Windows command prompt requires double quotes instead of single quotes but is otherwise the same.

Alex






-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to