Google translator:
Guys, prompt, really I create a variable named stream?
I want the next copy flow and rename it to a variable was created and written with the new name of the stream. {Flow_name} understandable. But how to create a recess with the same name?
For example. I want to ping the IP pieces 20. Every minute to write the log of the results. Then, when the state variable and the status of the ping, disappeared so to speak, I will send a sms with the text of the ping and the IP address.
Can anyone implemented such a thing?
Or please tell me how to file a list of IP by turns to take each line and ping this address.
Write to a file ravine easy. Understood.
By ftp or something else is taken from time to time files:
1. hosts
2. phonenumbers
3. log
Taken one by one the IP address of the hosts file and ping.
(Host reacheble ping)
Is compared with the current state of the Previous and the difference is sent SMS.
SMS is formed on the result of the passage of all addresses. Infa accumulates and then sent.
"/ N" works as a new line? printed only as text and everything. Maybe the code should be some kind?
Just please tell me the procedure (code) to read a line from a file and writes to the array a. On the arduino can do, and then what?
There is a file: hosts. it placed the IP address line (20 pieces, strings).
Pinging each address one time per minute.
Compare the current state of the IP address (192.168.0.1) to the last variable ("192.168.0.1").
If different, write to another variable "TEXTtoSMS": IP address, date, time, current status.
Write to the variable ("192.168.0.1") the current status of the address.
And so for each IP address of the file.
When all the rows have been (address) check for the presence of text in the variable "TEXTtoSMS" and send SMS to the addresses that I take from another file.
Do I need to somehow individually declare a variable? Or enough (stat_19216801 = "on")? I want to create a variable named stream. {Flow_name}. Really it?
Or it is necessary to enclose an array of two columns? The first IP address, the second status. After checking the status of an IP address, run the array. Looking in the first column of our address and check the option recorded in the second column. How do I proceed with the formation of protsedurka "TEXTtoSMS" ..
How to add a translation to a new line when writing text into a variable "TEXTtoSMS"?
ping adresses from file, send sms report to adresses by list
Moderator: Martin
Re: ping adresses from file, send sms report to adresses by
files:
1. hosts:
192.168.0.1
192.168.0.2
......
.
.
..
2. calls:
+7********
+7********
+7********
3. log:
ip adress, date, time, status (online, ofline)
1. need to read from file HOSTS, ip adress from line1 and ping. Or get all lines from file HOSTS to array with 2 columns. Frist column for ip adress, second column for previous status (online, ofline).
For each ip need ping then compare now status with previous status.
If status changed, add to value "TEXTtoSMS" (ip, status). At the end of string add "/n", for insert code NEXT STRING (like in Arduino "Println(text)").
Please give me code (example) for read strings from file. Line1, Line2, Line3.
Or get strings from file to array.
I need just it. Next steps not strong for me.
1. hosts:
192.168.0.1
192.168.0.2
......
.
.
..
2. calls:
+7********
+7********
+7********
3. log:
ip adress, date, time, status (online, ofline)
1. need to read from file HOSTS, ip adress from line1 and ping. Or get all lines from file HOSTS to array with 2 columns. Frist column for ip adress, second column for previous status (online, ofline).
For each ip need ping then compare now status with previous status.
If status changed, add to value "TEXTtoSMS" (ip, status). At the end of string add "/n", for insert code NEXT STRING (like in Arduino "Println(text)").
Please give me code (example) for read strings from file. Line1, Line2, Line3.
Or get strings from file to array.
I need just it. Next steps not strong for me.
Re: ping adresses from file, send sms report to adresses by
You could use the action Init Variable Text File to read the file into a variable and then use function split to create a list of lines. Check out the examples page and scroll down to Create a list of lines from a multiline text.
Another approach would be to use function splitCSVRecords to create a list of lines each containing the list of values.
The file hosts could look like this:
192.168.0.1,0
192.168.0.2,0
...
The variable contains an entry for each line. Each line consists of another list, IP at index 0 and the status at index 1.
When you have tested and updated all the status of all IPs, you could use following script to create multiline text again:
The CSV approach would also allow to put the phone number into the same file.
192.168.0.1,+7********,0
192.168.0.2,+7********,0
Regards,
Martin
Another approach would be to use function splitCSVRecords to create a list of lines each containing the list of values.
The file hosts could look like this:
192.168.0.1,0
192.168.0.2,0
...
Code: Select all
text="192.168.1.1,0\n192.168.1.2,0";
list=splitCSVRecords(text);
Code: Select all
first_ip_with_result=getElement(list, 0);
old_status=removeElement(first_ip_with_result, 1);
new_status=1; //change the status, just an example, would be set in a loop with a condition [b]Host Reachable[/b]
addElement(first_ip_with_result, new_status);
Code: Select all
result="{list,listformat,comma}";
192.168.0.1,+7********,0
192.168.0.2,+7********,0
Regards,
Martin