write an rpgle program and ibm cl to ping and store the results in a physical file
user
creating an rpgle program to ping a host and store the results in a physical file involves several steps. i'll provide the ibm cl commands and rpgle code for your ibm i (as/400, iseries) system. this example assumes you're running operating system version 7.3 or later.

first, let's create a physical file to store the results. use the following ibm cl commands:
```perl
//create a physical file with a filename and empnsize
//this file will store the ping results
crtfil fkpgingrles obj('lib/ping_results.txt') spec ('varchar(*n)')
   ds day shrlen(50) dsshell(c'/rfpd ta=altc spt=errblt')
```
next, we'll create a service program to perform the ping operation. use the following cl commands to generate the service program:
```ruby
//generate a service program for the ping operation
//include the cmd washington university ping function
//mylibrary is the library where the ping function is located
rgzpfm pkg(*now) servpgm(*pgm) gthndl(*none) titl('pingsvrc')
   func(*pingsvr) obj(*none) spec(*pgmxc) bndcndl(0)
   dftactp1(*bnd) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftactp2(*in) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftactp3(*out) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftactp4(*ret) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftactp5(*hndl) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftactp6(*wto) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftactp7(*prcd) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   func(*ping) obj(*none) spec(*pgmxl) bndcndl(0)
   dftpp1(*in) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftpp2(*ref) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftpp3(*out) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftpp4(*hndpar) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
   dftpp5(*write) rqdt(1) rqdsn(*yes) text('pingsvrc') typ(600)
```
now that we have the service program, we can create the rpgle program:
```rpgle
//procedure to call the service program and store the results in the physical file
//incluir irqgeti para controlar a exclusão múltipla
//mylibrary is the library where the ping function is located
dcl       fc_ping_ret    bin(*yes) sdh(*retirql) qry(*none) cnt(*inc) len(10);
dcl       fc_ping_ctl    bin(*yes) sdh(*retirql) qry(*none) cnt(*inc) len(10);
dcl       sd_pingresult  ods(*text)  sdh(*inc) len(50);

pgm
assistant
Creating an RPGLE program to ping a host and store the results in a physical file involves several steps. I'll provide the IBM CL commands and RPGLE code for your IBM i (AS/400, iSeries) system. This example assumes you're running Operating System version 7.3 or later.

First, let's create a physical file to store the results. Use the following IBM CL commands:
```perl
//Create a physical file with a filename and empnsize
//This file will store the ping results
CRTFIL FKPGINGRLES OBJ('lib/ping_results.txt') SPEC ('VARCHAR(*N)')
   DS Day SHRLEN(50) DSShell(C'/rfpd ta=altc SPT=ERRBLT')
```
Next, we'll create a service program to perform the ping operation. Use the following CL commands to generate the service program:
```ruby
//Generate a service program for the ping operation
//Include the CMD Washington University PING function
//MyLibrary is the library where the ping function is located
RGZPFM PKG(*NOW) SERVPGM(*PGM) GTHNDL(*NONE) TITL('PINGSVRC')
   Func(*PINGSVR) OBJ(*NONE) SPEC(*pgmxc) BNDCNDL(0)
   DFTACTP1(*BND) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTACTP2(*IN) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTACTP3(*OUT) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTACTP4(*RET) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTACTP5(*HNDL) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTACTP6(*WTO) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTACTP7(*PRCD) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   Func(*PING) OBJ(*NONE) SPEC(*pgmxl) BNDCNDL(0)
   DFTPP1(*IN) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTPP2(*REF) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTPP3(*OUT) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTPP4(*HNDPAR) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
   DFTPP5(*WRITE) RQDT(1) RQDSN(*YES) TEXT('PINGSVRC') TYP(600)
```
Now that we have the service program, we can create the RPGLE program:
```rpgle
//Procedure to call the service program and store the results in the physical file
//Incluir IRQGETI para controlar a exclusão múltipla
//MyLibrary is the library where the ping function is located
Dcl       Fc_Ping_Ret    Bin(*Yes) Sdh(*RetIrql) Qry(*NONE) Cnt(*Inc) Len(10);
Dcl       Fc_Ping_Ctl    Bin(*Yes) Sdh(*RetIrql) Qry(*NONE) Cnt(*Inc) Len(10);
Dcl       Sd_PingResult  Ods(*TEXT)  Sdh(*Inc) Len(50);

Pgm
assistant