1.

Solve : Need to create a batchfile, which sends Alerts?

Answer»

set[highlight] [/highlight]ip=[highlight] [/highlight]132.122.6.5[highlight] [/highlight]132.122.6.4
for %%i in ("%ip%") do (
ping -n 2 %%i > nul
if errorlevel 1 (
echo Ping failed: %%i
blat c:\emp.txt -to [emailprotected] -subject "Agara is Down"
)
)

I am again posting my batch file with the highlited area, which actually indicate a space.
I really failed to understand, why it failed to ping, when the i.p's are correct. you just do me your favour, one more time, because , as described by you, I am prety much sure that I've USED the space in highlited area.

hare krishna
Alok
Try this, I removed the quotes AROUND the %ip% variable. Also there should be no space between the equals and the first digit of the first ip address. The set statement takes everything literally and spaces are valid characters.

Code: [Select]@echo off
set ip=132.122.6.5 132.122.6.4
for %%i in (%ip%) do (
ping -n 2 %%i > nul
if errorlevel 1 (
echo Ping failed: %%i
blat c:\emp.txt -to [emailprotected] -subject "Agara is Down"
)
)

Lets start the weekend right and get this thread finished.
Thanks a lot winder, I finally make it work. that's really great! Anyways, I just need one more favour. Can't I use mail_body inside blat, like I used in subject "Agara is down". I just don't want to put the file NAME, I just wanted to put some custome massage inside blat.

hare krishna
Alok


It would be helpful if you posted the working version so everyone could see it. APPARENTLY there is a -body switch where you can put your text.

See: Blat Syntax

8-)

Thanks Winder, Once again. I managed to make it run with the help of the GIVEN link.


hare krishna
Alok



Discussion

No Comment Found