ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

PING from /free

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

  • PING from /free

    Hi, Can someone post me an example of a PING from rpg free which has error trapping. i.e. PING not successful.

    I guess it's using the QCMDEXC.. in fact how do you monitor for errors when using this command?

    Thanks

    Huddy
    www.midlifegamers.co.uk

  • #2
    Re: PING from /free

    I can post you some code when I get home tonight.
    IIRC ... i did it with CL.
    Regards

    Kit
    http://www.ecofitonline.com
    DeskfIT - ChangefIT - XrefIT
    ___________________________________
    There are only 3 kinds of people -
    Those that can count and those that can't.

    Comment


    • #3
      Re: PING from /free

      tis okay , i found this..

      Code:
       
      monitor;
      QCMDEXC( 'PING RMTSYS([URL="http://www.ibm.com/"]WWW.IBM.COM[/URL]) MSGMODE(*VERBOSE *ESCAPE)' : 51 );
      PingOk = *on;
      on-error;
      PingOk = *off;
      endmon;
      Needs to be in a monitor.

      Cheers

      Huddy
      Last edited by kitvb1; June 21, 2010, 08:25 AM. Reason: added code block using # icon
      www.midlifegamers.co.uk

      Comment


      • #4
        Re: PING from /free

        this does work ... just thought I'd wake the dead thread.
        I needed this because of tracking machines on the shop floor using LXE wireless devices.
        when the LXE unit {EXPLODES} and a substitute is put into production, I needed a way
        to automatically check to see if the unit is active. There is much more code involved but this
        is the core.

        PHP Code:

        d cmdlength       s             15  5                                      
        d cmdstring       s            512                                         
        d
        *ipaddress       s             13    inz('10.0.10.128')                   
        d ipaddress       s             13    inz('10.0.10.199')                   
        d pingOK          s               n                                        
        d Q               s              1    inz
        ('''')                            
                                                                                   
        d $command        pr                  extpgm('QCMDEXC')                    
        d   command                    512                                         
        d   Length                      15  5                                      
                                                                                   
                                                                                   
         
        /Free                                                                     
                                                                                   
           cmdstring 
        'PING RMTSYS(' +  + %trim(Ipaddress) + ') ' +         
                       
        ' MSGMODE(*VERBOSE *ESCAPE)';                               
           
        cmdlength = %len(%trim(cmdstring));                                     
                                                                                   
           
        monitor;    
            
        $command (cmdstringcmdlength);                
            
        PingOk = *on;                                   
           
        on-error;                                        
            
        PingOk = *off;                                  
           
        endmon;                                          
                                                            
           *
        inlr = *on;                                     
                                                            
         /
        End-Free 
        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: PING from /free

          Originally posted by jamief View Post
          this does work ... just thought I'd wake the dead thread.
          And just cause:

          Click image for larger version

Name:	deadthrd.jpg
Views:	6
Size:	68.9 KB
ID:	126558

          Comment


          • #6
            Re: PING from /free

            Originally posted by kitvb1 View Post
            I can post you some code when I get home tonight.
            IIRC ... i did it with CL.
            and Kit is still on his way home....

            Comment


            • #7
              Re: PING from /free

              Originally posted by dhanuxp View Post
              and Kit is still on his way home....
              I'm getting older ... it takes me a while but I'm almost there
              Regards

              Kit
              http://www.ecofitonline.com
              DeskfIT - ChangefIT - XrefIT
              ___________________________________
              There are only 3 kinds of people -
              Those that can count and those that can't.

              Comment


              • #8
                Re: PING from /free

                Originally posted by kitvb1 View Post
                I'm getting older ... it takes me a while but I'm almost there
                http://www.gpsies.com/map.do?fileId=rnjyypfxmkmwprug
                gosh! was that the "nice little ride" u posted in FB ?

                Comment


                • #9
                  Re: PING from /free

                  Yep... trying to get fit for the 220km (around) Lake Constance Marathon.
                  Regards

                  Kit
                  http://www.ecofitonline.com
                  DeskfIT - ChangefIT - XrefIT
                  ___________________________________
                  There are only 3 kinds of people -
                  Those that can count and those that can't.

                  Comment


                  • #10
                    Re: PING from /free

                    CL is for small children & farm animals...
                    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


                    • #11
                      I was searching on QCMDEXC w/ PING and this thread came up among others. I stumbled into using SQL call to invoke ping and I like this new method of invoking QCMDEXC, but hoping someone can clarify something for me.

                      In the example below I can use SQLCOD to check whether ping is successful, but the monitor statement does not. It seems to maybe just be verifying that invoking the command worked?

                      PHP Code:
                          monitor;                                                     
                          
                      exec sql CALL QSYS2.QCMDEXC                                  
                            
                      'PING RMTSYS(WWW.IBM.COM) MSGMODE(*VERBOSE *ESCAPE)' );  

                        
                      // this does not work to test valid ping                                          
                            
                      PingOk = *on;                                              
                          
                      on-error;                                                    
                            
                      PingOk = *off;                                             
                          
                      endmon;                                                      

                        
                      // this works to test valid ping                                                 
                            
                      if SQLCOD 0;                                             
                              
                      PingOk = *on;                                            
                            endIf; 

                      Comment


                      • #12
                        Can you explain why you are using SQL? This seems like an odd thing to do since you're in an RPG program that can easily call QCMDEXC directly (like the earlier examples in the thread) and elimimate the extra complexity of having SQL involved.

                        Comment


                        • #13
                          Because I can do what I need with about 12 less lines of code...

                          Comment

                          Working...
                          X