Perl Script Problem

Anthony Gardner cyclewood_ltd at yahoo.co.uk
Thu Nov 15 13:10:03 UTC 2007


Your logic still seems a bit wrong. Have a look at the following 2 examples. Maybe they express what you want to do. Or maybe not.

I've used elsif because in your example, the other conditions will still be tested. Your >= 999 I think should be <=999

if ($error == 0) {
   system ("/vmbackup/send.sh -u Backup complete.");

  } elsif ($error > 0 and $error <= 999) {
    system ("/vmbackup/send.sh -u Backup error");

} else    ##if ($error > 1000) {
   system ("/vmbackup/send.sh -u Backup error, snapshot available");

}

if ($error == 0) {
    system ("/vmbackup/send.sh -u Backup complete.");
 
   } elsif ($error > 0 and $error <= 999) {
     system ("/vmbackup/send.sh -u Backup error");
 
 } elsif ($error > 1000) {
    system ("/vmbackup/send.sh -u Backup error, snapshot available");

 } else {
  ## maybe a - (minus) return code, I dunno
}

-Ants

Anton Hofmann <doomrunner.lists at gmail.com> wrote: -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Felipe Figueiredo schrieb:
> A Thursday 15 November 2007 08:47:28, Anton Hofmann escreveu:
> 
> Try using parenthesis in each test
> ( ($error >= "0") and ($error <= "999") )
> 
> also, why are you using string comparison operators (gt, le, eq...) for 
> integers? using <=, == and >= is more indicated (and prevents warnings when 
> you use -w, warnings and strict).

Hi Felipe,

my way was a litle bit stupid, as you say i used string comparison for
integer values, i changed it to:

if ($error == 0) {
 system ("/vmbackup/send.sh -u Backup complete.");
  }
if ($error > 0 and $error >= 999) {
  system ("/vmbackup/send.sh -u Backup error");
  }
if ($error > 1000) {
 system ("/vmbackup/send.sh -u Backup error, snapshot available");

now it works perfect.

thank you.

Anton



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)

iD8DBQFHPDfTUhOOK1n0VVkRAqNSAKCAfFuGIXE0ZH95EqmHAJQ3nbh7KACfZLPA
YLWFMt2SmnCGmPRDlg2QVIE=
=Xakc
-----END PGP SIGNATURE-----

-- 
ubuntu-users mailing list
ubuntu-users at lists.ubuntu.com
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users



Disclaimer: Technically, I'm always wrong!!
       
---------------------------------
 For ideas on reducing your carbon footprint visit Yahoo! For Good this month.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20071115/8702fab7/attachment.html>


More information about the ubuntu-users mailing list