How to do a SET using SNMP ?

Hi,
I already ask in the forum Advanced Language Topics
http://forum.java.sun.com/thread.jsp?forum=4&thread=320674
but I din't receive any answer so I try here maybe some one could help me on this ... ;-)
I find a nice piece of code on Internet to do SNMP request �
http://membres.lycos.fr/ysoun/index.html
http://membres.lycos.fr/ysoun/sck.zip
It works find to do some GET operations like doing a GET sysDescr (oid 1.3.6.1.2.1.1.1.0).
But I would like to do a SET operation but I could'nt succeed.
First I do a get on an oid 1.3.6.1.2.1.1.4.0 (sysContact) and I get the value "hello" which is find and I would like to set this value to "good bye".
Well I have to say that I don�t know very well the SNMP protocol and I couldn�t figure out where to put the value in order to set "Good bye". Off course I have the right community to do that but I just can't figure out how can I do that ...
Any comment ... help ... ideas ... are more than welcome !!!! Or maybe some better SNMP package to do that???
thanks,
Emmanuel
Here is the code:
the function to set using SNMP ...
  public static setSnmpRequest(int snmpPort, int snmpTimeout, String community, String host, String strValue){
      String oid = new String("1.3.6.1.2.1.1.4.0");
      D_SNMP.Message request;
      try {
          InetAddress snmpHost = InetAddress.getByName(host);
          DatagramSocket sock = new DatagramSocket();
          sock.setSoTimeout(snmpTimeout);
          // create pdu.
          //somewhere here I should include my variable "good bye" but I don't really know how
          Var var = new Var(oid);
          OctetString c = new OctetString(community);
          D_SNMP.Integer requestId = new D_SNMP.Integer(0);
          D_SNMP.Integer errorIndex = new D_SNMP.Integer(0);
          D_SNMP.Integer errorStatus = new D_SNMP.Integer(0);
          //For the GET:
          //PduCmd pdu = new PduCmd(Pdu.GET,requestId,errorStatus,errorIndex,new VarList(var));
          //What I would like to do:
          PduCmd pdu = new PduCmd(Pdu.SET,requestId,errorStatus,errorIndex,new VarList(var));
          D_SNMP.Message m = new D_SNMP.Message(c,pdu);
          // send
          byte[] b = m.codeBer();
          DatagramPacket packet = new DatagramPacket(b,b.length,snmpHost,snmpPort);
          byte[] b2 = new byte[1024];
          DatagramPacket p2 = new DatagramPacket(b2,b2.length);
          long startTime = System.currentTimeMillis();
          sock.send(packet);
          sock.receive(p2); // block or ... timeout.
          long time = (System.currentTimeMillis() - startTime);
          // display
          ByteArrayInputStream ber = new ByteArrayInputStream(b2,1,p2.getLength()-1); // without tag !
          D_SNMP.Message m2 = new D_SNMP.Message(ber);
          System.out.println("snmpPing " + host + " :");
          System.out.println(m2.getPdu().getVarList().elementAt(0) + " / time = " + time + "ms" );
          if (debug){
              StringBuffer buf = new StringBuffer();
              m2.println("",buf);
              System.out.println(buf);
      } catch (UnknownHostException ex){
          System.out.println(host + ": unknown host." );
      } catch (InterruptedIOException ex){
          System.out.println("snmpPing "+ host + " : Time-out." );
      } catch ( Exception ex) {
          System.out.println("Error in : ");
          System.out.println(ex);
  } the class Var... where somewhere I should be able to set the variable "Good bye" ...
import java.io.*;
import java.util.Vector;
/** ASN.1 grammar for Var:
* Var ::=
* SEQUENCE
*        { name Oid
*          value CHOICE {Null, Integer, Counter, gauge, Timeticks, IpAddress, OctetString}
final public class Var extends construct implements Serializable {
  public Var(Oid o, smi s){
    this();
    valeur.addElement(o);
    valeur.addElement(s);
  /** Same as Var(new Oid(oid), new Null()).
  public Var(String oid) throws IOException{
    this(new Oid(oid), new D_SNMP.Null());
  /** Builds a Var from a ByteArrayInputStream holding a Var Ber coding.
   *  <BR>Bytes read are removed from the stream.
   *  <P><B>Note:</B> The ByteArrayInputStream must not contain the Var Tag.
   *  @exception IOException is thrown if a problem occurs while trying to decode the stream.
  public Var(ByteArrayInputStream inBer) throws IOException{
    this();
    decodeBer(inBer);
  /** Used only by VarList.
  Var(){
    super(smi.SEQUENCE_tag);
    valeur = new Vector(2);
  /** Returns the name of this Var.
  public Oid getName(){
    return (Oid) valeur.elementAt(0);
  /** Returns the value of this Var.
  public smi getValue(){
    return (smi) valeur.elementAt(1);
  /** Returns the value of this Var as a String.
  public String toString() {
    try{
    return ((smi)valeur.elementAt(0)).toString() + " = " + ((smi)valeur.elementAt(1)).toString();
    }catch (IndexOutOfBoundsException e) { // ne doit pas se produire.
      System.out.println("Erreur codage interne type Var.");
      System.exit(1);
    return null;
  /** Used smi.decodeBer().
  void decodeValeur(ByteArrayInputStream bufferBer, int lgBerValeur) throws IOException {
    int tag = bufferBer.read();
    if ( tag != smi.OID_tag )
      throw new IOException ("erreur decodage tag Oid de Var: byte " + java.lang.Integer.toHexString(tag) +" recu.");
    Oid name = new Oid(bufferBer);
    this.valeur.addElement(name);
    // lis l'objet suivant.
    tag = bufferBer.read();
    try{
    smi _valeur = smiFactory.create(tag,bufferBer);
    this.valeur.addElement(_valeur);
    } catch (IOException e){
      throw new IOException ("erreur decodage champ Valeur : " + e);
  /** Custom serialization: Ber coding is written in ObjectOutputStream.
  private void writeObject(ObjectOutputStream out) throws IOException{
    byte b[] = this.codeBer();
    out.writeInt(b.length);
    out.write(b);
    out.flush();
  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    this._tag = smi.SEQUENCE_tag;
    this.valeur = new Vector();
    int len = in.readInt();
    byte b[] = new byte[len];
    in.readFully(b);
    this.decodeBer(new ByteArrayInputStream(b,1,b.length-1));
} the class VarList ...
import java.io.*;
import java.util.Vector;
/** ASN.1 grammar for VarList:
* VarList ::=
* SEQUENCE OF Var
final public class VarList extends construct {
  /** Constructs a VarList holding a single Var.
   *  @param Var to be held by Varlist
   public VarList(Var v){
     super(smi.SEQUENCE_tag);
     valeur = new Vector(1);
     valeur.addElement(v);
  /** Constructs a VarList holding Vars.
   *  @param v Vector of Vars.
   public VarList(Vector v){
     super(smi.SEQUENCE_tag);
     valeur = (Vector) v.clone();
   /** Constructs a VarList holding Vars.
   *  @param tab array of Vars.
   public VarList(Var[] tab){
     super(smi.SEQUENCE_tag);
     int taille = tab.length;
     valeur = new Vector(taille);
     for (int i=0; i<taille; i++)
       valeur.addElement(tab);
/** Builds a VarList from a ByteArrayInputStream holding a VarList Ber coding.
* <BR>Bytes read are removed from the stream.
* <P><B>Note:</B> The ByteArrayInputStream must not contain the Var Tag.
* @exception IOException is thrown if a problem occurs while trying to decode the stream.
public VarList(ByteArrayInputStream inBer) throws IOException{
super(smi.SEQUENCE_tag);
valeur = new Vector();
decodeBer(inBer);
/** Returns the Var at the specified index.
public Var elementAt(int i) throws IndexOutOfBoundsException {
return (Var)valeur.elementAt(i); // Sans soucis: Var est immutable
/** Returns the number of Var held this VarList.
public int getSize(){
return valeur.size();
/** Used by smi.decodeBer().
* A VarList is in fact an array of Vars.
void decodeValeur(ByteArrayInputStream bufferBer, int lgBerValeur) throws IOException {
Var v;
int lg;
try{
while (lgBerValeur >0){
int tag = bufferBer.read();
lgBerValeur --;
if ( tag != smi.SEQUENCE_tag )
throw new IOException ("error decoding tag Var in VarList: byte " +
java.lang.Integer.toHexString(tag) +" read.");
v =new Var();
lg = v.decodeBer(bufferBer);
this.valeur.addElement(v);
lgBerValeur -= lg;
} catch (IOException e){
throw new IOException ("error decoding Value : " + e);

I read the documentation it does not help me much, (it's generated by javadoc and there is not enought comment to understand the whole thing ... in fact it just miss a sample of SET request and it would be perfect ...
thanks,
emmanuel
PS: I'm going to try the author again
PS: Still ... any help or pakage to do SET request using SNMP are more than welcome ...

Similar Messages

  • How to Create BC SET using Transport Request

    Hi,
    How to Create BC SET using Transport Request.if any one knows help me

    Hi Gowri,
    The below given description might help u out ..
    You want to create a BC Set from a transport request. A transport request containing Customizing data must already exist.
    This Customizing request is a change request with which you can copy and transport the changed system settings.
    The BC Set is based on the data in the Customizing request. You can copy all the data records in the Customizing request into the BC Set, or select a subset.
    You can subsequently edit BC Sets created from transport requests.
    Procedure
    Enter the Customizing request number and Continue.
    -> You can search for requests with the F4 help. The request type is Workbench/Customizing requests. The request status is changeable or released.
    -> You get an overview of the transport objects in the transport request. To put a transport object in the BC Set, flag the row Copy.
    ->The Status column tells you the BC Set-compatibility of the transport object. It can have the following values:
    ·        green traffic light: The transport object can be put in the BC Set.
    ·        yellow traffic light: BC Set creation or activation problems are possible. Check whether all data records have been put in the BC Set, after you create it.
    ·        red traffic light: Table entries exist, but they cannot be interpreted. They cannot be put in the BC Set.
    ·        Cancel: The transport object cannot be interpreted or put in the BC Set.
    You can get detail information about the object at the bottom of the screen, by double-clicking on a row. For detailed information about messages, choose the icon in the Documentation column.
    The Activity column indicates the associated IMG activity. If no unique assignment is possible, the field is empty. To assign an activity or change an existing assignment, choose the Change Activity icon. Position the cursor on the IMG activity to which you want to assign the object, and choose Select.
    When you have made your choice, choose the Save Data from Transport Request icon.
    Make the necessary entries in the following dialog box Create Object Directory Entry. Choose Save.
    To create the BC Set with the selected rows, choose Save.  
    When you read the transport request, the data records are initially only read in the logon language. When you save the BC Set, all languages in the system are also put in the BC Set.
    You can edit the BC Set manually at any time. Proceed as described in Change BC Set.
    Reward if helpful.
    Thankyou,
    Regards.

  • How to bypass printer setting using abap code?

    Dear All,
    I want to bypass printer setting using abap code?
    I am printing sticker using a code and i dont want to display printer setting .
    I want direct ouput ?
    Regards
    Steve

    Are you using reports or scripts/smart forms? You can use the parameter for no_dialog = space(use the relevant parameter).

  • How to delete found set using Leopard preview

    Leopard (5.5) and Preview:
    When using the thumbnails I can select multiple pages to delete. I need to delete a found set of pages. If I search for "cover sheets" I get exactly what I want. However, I get a search list in the sidebar and can only delete one page at a time (ugh). I cannot find a way to delete the found set. No combination of keys allows me to select multiple pages of the found set, that only works in the thumbnail view and then I am looking at all of the pages again, not the found set.
    It looks like I cannot do this but it would be a useful feature.
    Thanks for any suggestions.

    Not sure why you posted this in the AirPort Express (AX) discussion area since your question has nothing to do with the AX nor with wireless networking.
    I suggest that you post your question in the OS 10.5 discussion area.

  • How to reboot Nexi using SNMP (tsMsgSend not supported)

    How does one reboot Nexus using SNMP?'
    Normally, I reboot IOS gear using:
    snmpset -c {private} {switch|router|whatever} tsMsgSend.0 i 2
                   tsMsgSend OBJECT-TYPE
                       SYNTAX  INTEGER {
                            nothing(1),
                            reload(2),
                            messagedone(3),
                            abort(4)
                       ACCESS  read-write
                       STATUS  mandatory
                       DESCRIPTION
                               "Sends the message. The value determines what
                               to do after the message has completed."
                       ::= { lts 9 }
    But our new Nexi (5000 and 7500) don't support tsMsgSend in various ways:
    N5K
    Reason: notWritable (That object does not support modification)
    Failed object: OLD-CISCO-TS-MIB::tsMsgSend.0
    N7K
    Reason: wrongValue (The set value is illegal or unsupported in some way)
    Failed object: OLD-CISCO-TS-MIB::tsMsgSend.0
    Yes, I have the following in the Nexi config files:
    snmp-server system-shutdown
    How does one reboot a Nexus using SNMP?
    --sk
    Stuart Kendrick
    FHCRC

    Hi,
    The only way that a device can be reloaded using SNMP is with the SNMP object tsMsgSend
    (1.3.6.1.4.1.9.2.9.9).
    As per the official Nexus MIB support list, the OID is not supported in NX-OS
    Thanks-
    Afroz
    [Do rate the useful posts]

  • How to add a file in Document Set using ECMA script?

    Hi,
    I want to upload a particular file into Document set using ECMA script.
    I can do it easily through C# but unable to achieve the same using ECMA Script.
    Any pointers or piece of code will be helpful.
    Thanx in advance :)
    "The Only Way To Get Smarter Is By Playing A Smarter Opponent"

    The following blog post provides a way to create a document set using ECMA:
    http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
    The following blog post provides a way to upload files into a document set using CSOM:
    http://www.c-sharpcorner.com/Blogs/12139/how-to-create-document-set-using-csom-in-sharepoint-2013.aspx
    See if you can follow the logic in the CSOM example to apply it to ECMA. Let me know if you have specific problems with it.
    Dimitri Ayrapetov (MCSE: SharePoint)

  • Set IP address of L3 switch using SNMP

    HI,
     I am using cisco catalust 3560-x series swtiches. And I am new to SNMP. I want to assign IP address to interfaces of this switch, using SNMP.  Kindly help me. Any help, any sugession, is most welcome.
    Thanks in advance
    Jeni A

    hi,
    Thanks for your response.
    Our requirement is as follows.
    I want to assign IP address to Switch fro my Java Application. I have implemented  a Telnet Client Code in Java, by which i can configure IP address in switch from my java application.
    But my boss said, Telnet is not secure and try using SNMP to do the same.
    When I was searching in Internet, I got this page https://supportforums.cisco.com/discussion/12090896/snmp-how-get-list-ip-addresses-and-corresponding-interface-names
    The above thread gives object ID to GET IP address of Switch interface. This Object is Read-only.
    In the similar way, is there any object, using which I can SET / assign IP address to switch interfaces.
    waiting for your response.
    Thanks in advance :)

  • HT204053 The entire family has used one itunes account for years. How do we all set up separate iCloud accounts now?

    The entire family has used one itunes account for years. How do we all set up separate iCloud accounts now? Or should we? 5 macbooks, 2 ipads, 4 iphones, 2 itouch, 2 imacs.   How does one decide what to sync, share and what not to? Green Jeans.

    You need to start by understanding the distinction between iTunes and iCloud - Apple confuse the issue by referring to 'iTunes Match' as part of iCloud. It isn't.
    You don't have to have the same login (Apple ID) for iTunes and iCloud; many people don't and there's no problem about it.
    Your iCloud ID gets you email, calendars, contacts, iWork documents and PhotoStream syncing between devices.
    Your iTunes ID gets you the iTunes Store, the App Store for iOS, the Mac App Store for OSX,, 'iTunes in the Cloud' (downloading of purchased items to any logged-in device) and 'iTunes Match' (uploading of songs not purchased in the iTunes Store).
    Your family members can easily each get their own iCloud account to keep email etc. separate - in each case they will need a different non-Apple email address (a free one from Yahoo etc. would do) to set up the ID. If they are sharing a Mac they need to be using a separate user account.
    They can have their own iCloud accounts and still all sign into the same iTunes account: or they can open their own iTunes accounts using their new iCloud Apple IDs.
    BUT they cannot transfer items purchased under the present iTunes ID to different iTunes IDs.

  • How to Submit a Concurrent Request Set Using a Self-Service Page

    Hi all,
    I would like to know how to Run/Submit a Concurrent Request Set Using a Self-Service Page
    Thanks.
    Bench

    Hi all,
    I would like to know how to Run/Submit a Concurrent Request Set Using a Self-Service Page
    Thanks.
    Bench

  • How to get Document Set property values in a SharePoint library in to a CSV file using Powershell

    Hi,
    How to get Document Set property values in a SharePoint library into a CSV file using Powershell?
    Any help would be greatly appreciated.
    Thank you.
    AA.

    Hi,
    According to your description, my understanding is that you want to you want to get document set property value in a SharePoint library and then export into a CSV file using PowerShell.
    I suggest you can get the document sets properties like the PowerShell Command below:
    [system.reflection.assembly]::loadwithpartialname("microsoft.sharepoint")
    $siteurl="http://sp2013sps/sites/test"
    $listname="Documents"
    $mysite=new-object microsoft.sharepoint.spsite($siteurl)
    $myweb=$mysite.openweb()
    $list=$myweb.lists[$listname]
    foreach($item in $list.items)
    if($item.contenttype.name -eq "Document Set")
    if($item.folder.itemcount -eq 0)
    write-host $item.title
    Then you can use Export-Csv PowerShell Command to export to a CSV file.
    More information:
    Powershell for document sets
    How to export data to CSV in PowerShell?
    Using the Export-Csv Cmdlet
    Thanks
    Best Regards
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • There is a feature on the Ad on using iPad with apple tv as a dual screen such as the iPad as agame controller, how is this being set up or done?

    There is a feature on the Ad on using iPad with apple tv as a dual screen such as the iPad as agame controller, how is this being set up or done?

    This is something the app developer enables within airplay mirroring.
    There is nothing you can do to enable that.
    If you are unsure how to enable mirroring
    http://support.apple.com/kb/HT5209?viewlocale=en_US&locale=en_US

  • How to return a set of data  by using webservice ?

    Hi.
    I am finding how to return a set of data by using java webservice that serves clients written by others such as VB. Net. Please help me !
    Thanks in advance.

    Check the how to on Accessing Oracle9iAS Java Web Service from a .NET Client
    http://otn.oracle.com/sample_code/tech/java/codesnippet/webservices/index.html
    Chandar

  • How to change table value set using FND_LOAD

    Hi ,
    I need to change my existing " table valueset " tablename .
    As i know we cont change it from front end if it is created once. but i am trying to create same value set in other instance and uploading it using FND_LOAD .
    Is it Possible ?
    IF yes please guide ?
    I feel greate if any one helps me.
    Regards ,
    Azam.

    Hi,
    You could use FNDLOAD to download the values, and edit the ldt file before uploading it back using FNDLOAD.
    Search My Oracle Support for "FNDLOAD afffload.lct", you should get couple of hits which should be helpful.
    Note: 252853.1 - 11i AOL : How to Load Value Set Values When Using Fndload To Load A Concurrent Program
    Note: 274528.1 - How To Download Single Context Using FNDLOAD For Descriptive Flexfield
    Regards,
    Hussein

  • How to change a folder layout set using KM api?

    Hello,
    I'm developing a program using KM api that creates different folders with properties, permissions, ... I want to use a different layout set depending on the folder that i am browsing, but these folders are created dinamically, so I cant set a different layouts set for each one manually (Details > Display > ...).
    Does anybody know how I could do it using KM api? I mean, that every time I create a folder using KM api I should assaing dinamically the default layout set for this folder. I searched in the api and examples and I didn't find anything.
    Thanks in advance and best regards,
    JC

    Hi all,
    Problem solved... I decompiled standard code and I did what SAP do when they want to change a folder layout set:
    IResourceContext context = ResourceFactory.getInstance().getServiceContext("cmadmin_service");
    com.sapportals.portal.security.usermanagement.IUser puser = context.getUser();
    ICollection collection = (ICollection)ResourceFactory.getInstance().getResource(RID.getRID("folder_path"),context);
    IRepositoryServiceFactory factory = ResourceFactory.getInstance().getServiceFactory();
    ILayoutService layoutService = (ILayoutService)factory.getRepositoryService(collection, "LayoutRepositoryService");
    ILayoutContext userContext = layoutService.getContextForUser(puser, "");
    ContextProperties commonProperties = new ContextProperties(layoutService, collection, userContext.getAnonymousContext(), layoutService.getProfiles(), new HashMap());
    commonProperties.initFromPersistence();
    commonProperties.setSelectedProfileID("LayoutSetProfile");
    commonProperties.setSelectedLayoutsetID("ID_of_my_layout_set");
    ArrayList errormsg = new ArrayList();
    commonProperties.save(null, errormsg, false);
    Thanks and regards,
    jc!

  • How I can delete set of book that not use, it is creating wrongly?

    Dear Valued Consultant ,
    How I can delete set of book that not use, it is creating wrongly?
    Is there a way to delete Set of Book that not use, it is created wrongly?
    The Goal:
    This wrongly set of book it is appears always in any where that need select the Set of Book that may be cause select the wrongly one
    Thanks for alawys Helping

    Pl see if ML Doc 160623.1 (How to Delete a Set of Books from General Ledger?) helps.
    HTH
    Srini

Maybe you are looking for