I do not get why there is not a _icmp command in qb64 that would give results to a pinged IP address internally.
So what I have done is shelled to dos and run the ping ip -n 1 and captured it to a file then read that file looking or the results sent = a pass or fail number.
I also create a external config file to get the ip of each machine I a testing for up or down.
So I open he config get 1.1.1.1 and then left until I get the the end of the value and pass that to the command to ping with find the results of sent and received as equalling each other then print the entire line in green it if failed the sent and lost would equal and print in red. Ok good then I return to the topish to get the next ip in the config file and do that again.
That is where the issue appears the code wont do the same thing and will sometimes show failed ips on ips that are up. So not sure about the type of loop I should have used I ended up with gotos as a last resort which got the program to the point it is now.
The next thing I wanted to do was make it run faster and add a second column for the ips when there are more then X number in the first one but that is when I caught the issue and focused on it instead of the other column.
I added some areas to try to see what is going on and the first run you see the values but the next loop is where things go wonky.
Config$ = "Config.ini"
Pingfile$ = "ip1.tmp"
1
locateline = 5
'No Config file create file for user with sample data
PRINT "File missing, Creating " + Config$
+ "" PRINT "Eg. 192.168.1.1 Router" PRINT "Eg. 192.168.1.2 File Server" WRITE #file1
, "192.168.1.1 Router" WRITE #file1
, "192.168.1.254 Wifi Access Point" PRINT "File created with data." 'open Config file to get ips to check
2
'find ip in config file to send to ping command
3
'S and T just to trouble shoot and see what is going on
T = 5
S = 12
locateline = locateline + 1
'locate IPLength part in config file
LOCATE S
, T:
PRINT "*" + IPvalue$
+ "* line value of config file" IPLength = IPLength + 1
a$
= MID$(IPvalue$
, IPLength
, 1)'Dos Ping
22
IPCount = IPCount + 1
'*********problem area*********
LOCATE S
+ 1, T:
PRINT "*"; IPLength
- 1;
"* length of ip -1" LOCATE S
+ 2, T:
PRINT "*" + LEFT$(IPvalue$
, IPLength
- 1) + "* value determined from config file"
Comand$
= "cmd /c ping " + LEFT$(IPvalue$
, IPLength
- 1) + " -n 1 > " + Pingfile$
LOCATE S
+ 3, T:
PRINT "*" + Comand$
+ "* command to send shell"
'Get Ping status
IF LEFT$(Status$
, 32) = "Ping request could not find host" THEN Status$
= " Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),":
EXIT DO 'Set Up Down Statues
Receive
= VAL(MID$(Status$
, 35, 1))'testing print of values
LOCATE S
+ 4:
PRINT "*", Sent
, Receive
, Lost
, "*", " Sent Recived Lost Values from shell" Colum1 = 5
'Return to ping start for next value in config
INPUT "press enter for next loop", A
' close and startover from the top
99
A config.ini file would be a txt tile that looks like
1.1.1.1 DNS Server
192.168.1.1 house router
8.8.8.8 DNS Server
google.com google website this would be the next part for me to work on is host names instead of absolute ips.
The program should read over until it finds the space at the end of the ip the rest is the description of what that ip represents.