Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Ping?

From: doug:vos:eds at: 9-Feb-2001 15:54

... so here is a "way to ping with REBOL..." 1. REBOL writes the batch file 2. you run the batch/shell file 3. the last line in the batch file calls next REBOL script... ;------------------------------------------------------------ This script will ping every static IP address in a DHCP tab file to see if the device is still there. Then the DHCP admin can clean up DHCP for devices that have been shut off or moved to a different LAN segment.... It works by creating a batch file (.BAT) You could modify it for other platforms... eg. UNIX/LINUX shell The main guts of the script is the following few lines: { fwrite rejoin [ {echo. } ip/host-name { > } fname newline {ping } ip/ip-addr { >> } fname ] } It creates a file of ping results for each device, like %/ping-result-path/198.99.1.11.txt If you want the other files, that go along with this let me know...
<snip>
REBOL [ Title: "Ping batch file creator." File: %ping-bat-maker.r Version: 0.1.1 Date: 9-Feb-2001 Author: "Douglas Vos" E-Mail: [doug--vos--eds--com] Purpose: {Read in a file of devices from DHCP file and output a batchfile that will ping all the devices.} History: [ 0.1.0 [2-Feb-2001 {Began script.} "DJV"] 0.1.1 [9-Feb-2001 {Now calls parse-dhcp-lib.r to parse DHCP tab file in native format rather than working from temporary file.} DJV ] ] ] ;------------------------------------------------------------------------ ;----------- DECLARE THE GLOBAL VARIABLES in object gv ------------------ ;------------------------------------------------------------------------ gv: make object! [ dhcp-native: %/c/data/dhcp/rc/rn1_dhcp3tab.txt outpfile: %/c/data/pings/rc/pings.bat ] ;------------------------------------------------------------------------ ;-------------------- LOAD ANY REQUIRED EXTERNAL LIBRARIES -------------- ;------------------------------------------------------------------------ do join pc-path %parse-dhcp-lib.r ;------------------------------------------------------------------------ ;--------------------- DEFINE ANY HELPER FUNCTIONS ---------------------- ;------------------------------------------------------------------------ fwrite: func [ {Write output to specified file.} item [string!] {String to write to file - c/r will be appended.} ][ write/append/lines gv/outpfile item ] ;------------------------------------------------------------------------ ;------------- BEGIN MAIN PROCESS OF SCRIPT ----------------------------- ;------------------------------------------------------------------------ if exists? gv/outpfile [delete gv/outpfile] print [{Reading DHCP file: } gv/dhcp-native ] xips: filter-devices (parse-dhcp-file gv/dhcp-native) "STAT" print [{Writing batch-file of STATIC addresses to ping: } gv/outpfile] fwrite {DEL *.txt} foreach ip xips [ fname: rejoin [ip/ip-addr ".txt" ] fwrite rejoin [ {echo. } ip/host-name { > } fname newline {ping } ip/ip-addr { >> } fname ] ] fwrite {cd \rebol\core-2-3} fwrite {rebol -s --script %/e/scripts/rs/pingxlate.r} </snip>