in reply to Grabbing Process Status..

It looks like Perl, but it's heavily accented. Consider:
while (<BPCONF>) { my ($server) = unpack ("@10 A10", $_); if (($server eq "SERVER = cluster") && ($ps ne "daemon")) { print "Server entry is correct\n"; exit (110); } else { print "Server entry is incorrect\n"; exit (100); } }
Notes on the changes: Other than that, make sure you use strict and -w.

Here's a few ways to get your $server value, all pretty much equivalent:
my $server = substr($_, 10, 10); my ($server) = /^.{10}(.{10})/;
Using a regular expression is generally better, especially if you're not sure precisely where the data is going to be, index wise. If you were looking for "SERVER", your code might resemble this:
while (<BPCONF>) { if (/SERVER = cluster/ && $ps eq "daemon") { print "Server entry is correct\n"; exit (110); } else { print "Server entry is incorrect\n"; exit (100); } }

Replies are listed 'Best First'.
Re: Re: Grabbing Process Status..
by raj8 (Sexton) on May 09, 2002 at 02:17 UTC
    Thanks very much for your help and thanks for the share of knowledge on the server entry. The first line in the file that I was opening was SERVER = cluster. Therefore, I was trying to get the cluster part even they goofed and put additional spaces before or after the = sign. Once again, thanks for the help.
      If you have no idea how many spaces are going to appear there, if any, maybe you could use this instead:
      if ((/SERVER\s*=\s*cluster/) ...
      This will test for zero or more (*) spaces (\s) between those three parts. They can put in 500,000 and it won't affect your program.