Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Need to create a batchfile, which sends Alerts  (Read 29063 times)

0 Members and 1 Guest are viewing this topic.

Alok_Kumar

  • Guest
Re: Need to create a batchfile, which sends Alerts
« Reply #30 on: February 23, 2007, 05:06:11 AM »
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 [email protected] -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
« Last Edit: February 23, 2007, 05:08:52 AM by Alok_Kumar »

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Need to create a batchfile, which sends Alerts
« Reply #31 on: February 23, 2007, 07:39:10 AM »
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 [email protected] -subject "Agara is Down"
    )
 )

Lets start the weekend right and get this thread finished. :D
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Alok_Kumar

  • Guest
Re: Need to create a batchfile, which sends Alerts
« Reply #32 on: February 25, 2007, 11:01:06 PM »

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



Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Need to create a batchfile, which sends Alerts
« Reply #33 on: February 26, 2007, 05:11:01 AM »
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-)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Alok_Kumar

  • Guest
Re: Need to create a batchfile, which sends Alerts
« Reply #34 on: February 26, 2007, 05:41:21 AM »


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


hare krishna
Alok