setting a variable with a ping result
Moderator: DosItHelp
-
- Posts: 5
- Joined: 22 Jun 2013 21:27
setting a variable with a ping result
hi guys!
i have this code:
ping -n 1 00.00.000.00 | find "Reply" >> icms_ping_log.txt
i want to put the result of "reply" into a variable instead of a text file.
how would i go about doing that or is there documentation that i can read that would help me with this?
thanks in advance for your assistance!!
i have this code:
ping -n 1 00.00.000.00 | find "Reply" >> icms_ping_log.txt
i want to put the result of "reply" into a variable instead of a text file.
how would i go about doing that or is there documentation that i can read that would help me with this?
thanks in advance for your assistance!!
Re: setting a variable with a ping result
Code: Select all
FOR /F "delims=" %%G in ('ping -n 1 00.00.000.00 ^| find "Reply"') DO SET pingreply=%%G
-
- Posts: 5
- Joined: 22 Jun 2013 21:27
Re: setting a variable with a ping result
thanks for the reply, squashman!
now, how could i insert the value in %%G into a textfile?
what i'm trying to do is create a data set into a text file. simple data set with two columns.
so, my result would be something like this in a text file
ip-address, result
00.00.000.00, whatever result
00.00.000.00, whatever result 2
of course the code has a loop in there.
now, how could i insert the value in %%G into a textfile?
what i'm trying to do is create a data set into a text file. simple data set with two columns.
so, my result would be something like this in a text file
ip-address, result
00.00.000.00, whatever result
00.00.000.00, whatever result 2
of course the code has a loop in there.
Re: setting a variable with a ping result
Schoolwork?
-
- Posts: 5
- Joined: 22 Jun 2013 21:27
Re: setting a variable with a ping result
foxidrive, personal enhancement
Re: setting a variable with a ping result
You need to explain better what you want out of this BATCH file.
Your original code was output to a text file and then you asked for it in a variable and now you want it back to a text file. Please clarify what you are doing! You are wasting everyone's time by rewriting the code every time you come back with another question.
Your original code was output to a text file and then you asked for it in a variable and now you want it back to a text file. Please clarify what you are doing! You are wasting everyone's time by rewriting the code every time you come back with another question.
-
- Posts: 5
- Joined: 22 Jun 2013 21:27
Re: setting a variable with a ping result
sorry squashman, don't mean to waste your time.
i really appreciated your first assistance.
i thought that my question was extremely simple:
put a value in a variable, then put that variable in a text file. Should be easy.
i wanted to figure the code out on my own based on what you have provided.
as i explained in the my last post, i'm trying to create a data set recording ping replies.
i really appreciated your first assistance.
i thought that my question was extremely simple:
put a value in a variable, then put that variable in a text file. Should be easy.
i wanted to figure the code out on my own based on what you have provided.
as i explained in the my last post, i'm trying to create a data set recording ping replies.
-
- Posts: 5
- Joined: 22 Jun 2013 21:27
Re: setting a variable with a ping result
by the way, if anyone can suggest a book or documentation related to my question. that would be extremely appreciated.
new to this batch file programming, but not new to programming.
new to this batch file programming, but not new to programming.
Re: setting a variable with a ping result
bf_prg-bgnr wrote:by the way, if anyone can suggest a book or documentation related to my question. that would be extremely appreciated.
new to this batch file programming, but not new to programming.
What is wrong with our main website?
Re: setting a variable with a ping result
bf_prg-bgnr wrote:i thought that my question was extremely simple:
put a value in a variable, then put that variable in a text file. Should be easy.
The problem is you changed the parameters of your problem. You need to explain everything up front so that the code can be written once instead of rewriting the code. Has nothing to do with you thinking it is simple or easy. It is a lack of communication.
Code: Select all
FOR /F "tokens=3* delims=: " %%G in ('ping -n 1 00.00.000.00 ^| find "Reply"') DO >>icms_ping_log.txt echo %%G,%%H