ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Retrive windows name of my Pc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrive windows name of my Pc

    Hi all, i'm trying to use the program posted in this following thread
    ( http://groups.google.com/group/comp...044e8ec7d# ) but i have some problem:

    i run the following command
    CALL PGM($$APCNAM)
    PARM('MYWRKSTNID' ' ' ' ')

    with debug i see the IpAddress with the right value the IP32Addr with
    the following value 184353849 (that i don't kwon what can be) but the
    value of HOSTENTP = SPP:*NULL after the Call Procedure
    "gethostbyaddr"

    can some one help me ?
    Thanks

  • #2
    Re: Retrive windows name of my Pc

    can we see the code for $$APCNAM
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Retrive windows name of my Pc

      Here the source (that i copied from http://groups.google.com/group/comp...044e8ec7d# )

      Code:
             process nomonoprc                                          
             IDENTIFICATION DIVISION.                                   
             PROGRAM-ID.    RTVIPNAME.                                  
             AUTHOR.   AD.                                              
             ENVIRONMENT DIVISION.                                      
             CONFIGURATION SECTION.                                     
             INPUT-OUTPUT SECTION.                                      
             FILE-CONTROL.                                              
             DATA DIVISION.                                             
             FILE SECTION.                                              
             WORKING-STORAGE SECTION.                                   
             01  QdcrdevdParm.                                          
               05  QdcrdevdReceiver.                                    
                   10  Filler             Pic X(858).                   
                   10  QdcrdevdProtocol   Pic X(001).                   
                       88  IpProtocol     Value X"02".                  
                   10  Filler             Pic X(018).                   
                   10  QdcrdevdIpAddress  Pic X(015).                   
               05  QdcrdevdRecLength      PIC S9(09) Comp-4 value 892.  
               05  QdcrdevdFormat         PIC x(08) Value "DEVD0600".   
               05  QdcrdevdDeviceName     PIC x(10).                    
             01  ErrorCode.                                             
               05  ErrorBytesProvided  PIC 9(09) COMP-4 VALUE 16.       
               05  ErrorBytesAvailable PIC 9(09) COMP-4.                         
               05  ErrorExceptionId    PIC X(07).                                
               05  Filler              PIC X(01).                                
             01  HostentP               pointer.                                 
             01  AddressType            PIC S9(09) Comp-4.                       
                        88  AFINET             Value 2.                          
             01  IP32Addr               Pic S9(09) Comp-4.                       
             Linkage Section.                                                    
             01  DeviceName              PIC X(10).                              
             01  IpAddress               PIC X(15).                              
             01  IpName                  PIC X(64).                              
             01  Hostent.                                                        
               05  namepointer         pointer.                                  
             01  GetIpName               PIC X(64).                              
             01  errno pic s9(9) binary.                                         
             PROCEDURE DIVISION using DeviceName                                 
                                              IpAddress                          
                                              IpName.                            
            *****************************************************************    
                     MainProgramRoutine.                                         
                         Move space      to IpName.                              
                         Move space      to IpAddress                            
                         Move space      to QdcrdevdReceiver.                    
                         Move DeviceName to QdcrdevdDeviceName.    
                         Call "QDCRDEVD" Using QdcrdevdReceiver                 
                                               QdcrdevdRecLength                
                                               QdcrdevdFormat                   
                                               QdcrdevdDeviceName               
                                               ErrorCode.                       
                 If  ErrorExceptionId  not = Space                              
                         GoBack.                                                
                     If  not IpProtocol                                         
                         GoBack.                                                
                     Move QdcrdevdIpAddress  to IpAddress.                      
                     Call Procedure "inet_addr" Using     QdcrdevdIpAddress     
                                                Returning IP32Addr.             
                      If  IP32Addr = -1                                         
                          GoBack.                                               
                      Set  AFINET             to true.                          
                      Call Procedure "gethostbyaddr"                            
                              Using       by Reference       IP32Addr           
                                        by Value length of IP32Addr             
                                        by value           AddressType          
                              Returning   HostentP.                             
                      call procedure "__h_errno" returning address of errno.    
                                if  HostentP = NULL                             
                                    continue                                    
                                else     
                                    set address of hostent to HostentP     
                                    if  NamePointer = NULL                 
                                        continue                           
                                    else                                   
                 set address of Getipname to NamePointer                   
                 Inspect GetIpName replacing all X"00" by X"40"            
                 Move GetIpName to IpName.                                 
                                GoBack.

      Thanks
      Last edited by tomholden; May 24, 2012, 08:07 AM.

      Comment


      • #4
        Re: Retrive windows name of my Pc

        OMG ... Thats the cobol version of this

        PHP Code:
                                                                                                            
                                                                                                            
             d Format          s              8A   Inz
        ('DEVD0600')                                          
             
        d ipaddress       s             15a                                                            
             d Rcvar           S           5000A   Inz                                                      
             d Varlen          S             10i 0 Inz
        (5000)                                                
                                                                                                            
             
        d $getipaddress   pr                  extpgm('QDCRDEVD')                                       
             
        d   rcvar                     5000                                                             
             d   varlen                      10i 0                                                          
             d   format                       8                                                             
             d   
        @job                        10                                                             
             d   apierror                   256                                                             
                                                                                                            
              
        //                                                                                            
              // Program Info                                                                               
              //                                                                                            
             
        d                SDS                                                                           
             d  
        @JOB                 244    253                                                             
                                                                                                            
                                                                                                            
             d APIError        ds                  Qualified                                                
             d  BytesP                 1      4I 0 inz
        (%size(apiError))                                     
             
        d  BytesA                 5      8I 0 inz(0)                                                   
             
        d  Messageid              9     15                                                             
             d  Reserved              16     16                                                             
             d  messagedta            17    256                                                             
                                                                                                            
                                                                                                            
                                                                                                            
                                                                                                            
                                                                                                            
              
        /free                                                                                         
                                                                                                            
                   $getipaddress
        rcvar   :                                                                 
                                  
        varlen  :                                                                 
                                  
        format  :                                                                 
                                  @
        job    :                                                                 
                                  
        Apierror                                                                  
                                           
        );                                                               
                   
        ipaddress = %substrcvar:878:15);                                                       
                   
        dsply ipaddress ' ';                                                                     
                                                                                                            
                   *
        inlr = *on;                                                                             
              /
        end-free 
        Look here for full format description
        All my answers were extracted from the "Big Dummy's Guide to the As400"
        and I take no responsibility for any of them.

        www.code400.com

        Comment


        • #5
          Re: Retrive windows name of my Pc

          +1 for the Free version

          Comment


          • #6
            Re: Retrive windows name of my Pc

            Sorry

            what does it means ??

            Thanks

            Comment

            Working...
            X