batch file writing...

Mirlyn

Well-Known Member
I need to know if a given command ran successfully and based on the output, run a second command.

I don't want to do a Kixstart setup, just regular batch file (so its independent of the server it runs on). I've tried directing the standard output to a file, then searching the file for a word/phrase and creating another file based on true/false presence of the phrase, then testing for the existance of that secondary file. However, even if nothing gets put in the file, it still creates a 0 byte file (whether the word/phrase exists in the primary file or not). Which throws everything off.

I want to first see which machines in a list are up (online). Then I want to restart all the ones that are online, and if they aren't up, I want a list/logfile of the machines that didn't respond to the ping.

I have it somewhat working now. It pings the machine and if its up, it logs in and restarts it. If its down, it still tries to log in and restart it (it'll eventually fail, but with an extended timeout).

Any idea how to do this? Is there a way to search a returned string for a word or phrase? One way is to call another batch file and check the filesize of the afore mentioned logfile and act based on it. But the sample code I've seen for it is rather large.

What do you think? :)
 
Top