Sponsored Content
Top Forums Shell Programming and Scripting Need help with writing a perl script Post 302260347 by radoulov on Thursday 20th of November 2008 09:21:01 AM
Old 11-20-2008
And also consider using this code, if you don't want to loose the - signs in the output Smilie

Code:
#! /usr/bin/env perl


use warnings;
use strict;

my ($Thresholds_f, $Queue) = 
  ('/users/tibprod/scripts/EMS_Queue_List_leaiprod.ls', 
  '/users/tibprod/scripts/ShowQueues_leaiprod.sh|');
my %Thresholds_h;

open TH, '<', $Thresholds_f  or die "$Thresholds_f: $!\n";
  
while (<TH>) {
  tr/"//d;
  my @Fields = split /\s+/;
  $Thresholds_h{$Fields[0]} = [@Fields[1,2]];
  }

close TH;  


open QUEUE, $Queue or die "$Queue: $!\n";

while (<QUEUE>) {
  next unless /\w+\s+/;
  my $Flag = 0;
  my @Fields = split /\s+/;
  while (my($Key, $Ref) = each %Thresholds_h) {
    my @Values = @$Ref;
    if ($Fields[0] =~ /^$Key$/) {
      if (($Values[0] =~ s/^"*-//) && $Fields[1] < $Values[0]) {
        print "\n$Fields[0] ...".
        "\n\n\t--> task threshold exceeded: \n\n\tcurrent status: ",
        $Fields[1], "\n\tthreshold:      -", $Values[0], "\n";
        $Flag++
        }
      if ($Fields[1] > $Values[0]) {
        printf "\n$Fields[0] ..." unless $Flag;
        print "\n\n\t--> task threshold exceeded: \n\n\tcurrent status: ",
        $Fields[1], "\n\tthreshold:      ", $Values[0], "\n";
        $Flag++
        }      
      if (($Values[1] =~ s/^"*-//) && $Fields[2] < $Values[1]) {
         printf "\n$Fields[0] ..." unless $Flag;
         print "\n\t--> listeners threshold exceeded: \n\n\tcurrent status: ",
        $Fields[2], "\n\tthreshold:      -", $Values[1], "\n";
        $Flag++
        }
      if ($Fields[2] > $Values[1]) {
        printf "\n$Fields[0] ..." unless $Flag;
        print "\n\n\t--> listeners threshold exceeded: \n\n\tcurrent status: ",
        $Fields[1], "\n\tthreshold:      ", $Values[0], "\n";
        }      
      }
    }
  }  
  
close QUEUE;

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing perl module

Hi, I'd like to create perl functions in separate file from my scripts. Does somebody know if it's possible to create and use a perl module without compiling it ? Thanks. (4 Replies)
Discussion started by: jo_aze
4 Replies

2. UNIX for Dummies Questions & Answers

Perl Unix Script Writing

Hi Folks, I posted a few days ago, thanks for the responses. My original question was for renaming files of sort 3p2325294.dgn in a directory containing multiple files. I need to drop the first 2 characters and the last in a unix script using Perl. How does it differ from using the Unix... (1 Reply)
Discussion started by: Dinkster
1 Replies

3. Shell Programming and Scripting

help for a perl script - writing to a data file

Hi, Here is my problem.. i have 2 files (file1, file2).. i have wrote the last two lines and first 4 lines of "file2" into two different variables .. say.. my $firstrec = `head -4 $file2`; my $lastrec = `tail -2 $file2`; and i write the rest of the file2 to a tmpfile and cat it with head... (2 Replies)
Discussion started by: meghana
2 Replies

4. UNIX for Dummies Questions & Answers

help in writing perl module

Hi i have written a perl script which was then converted to perl module by me. it works as expected. but i have to put it on many servers so i want to build a package for it. i dont know how to do that. just to check i copied perl module in "lib" directory which is working. ( directly copied... (1 Reply)
Discussion started by: zedex
1 Replies

5. Shell Programming and Scripting

Writing a Perl Script that processes multiple files

I want to write a Perl script that manipulates multiple files. In the directory, I have files 250.*chr$.ped where * is from 1 to 1000 and $ is from 1-22 for a total of 22 x 10,000 = 22,000 files. I want to write a script that only manipulates files 250.1chr*.ped where * is from 1 to 22.... (10 Replies)
Discussion started by: evelibertine
10 Replies

6. Programming

REQUIRE HELP IN WRITING A PERL SCRIPT

Hi everyone I am a beginner in perl and I am trying to write a perl script. Basically I want to separate gene entries from phenotype entries in a text file which contains huge number of records and copy them in a separate file. The gene entries will have * symbol after the line FIELD TI. A... (7 Replies)
Discussion started by: kaav06
7 Replies

7. Shell Programming and Scripting

Perl script for Calling a function and writing all its contents to a file

I have a function which does awk proceessing sub mergeDescription { system (q@awk -F'~' ' NR == FNR { A = $1 B = $2 C = $0 next } { n = split ( C, V, "~" ) if... (3 Replies)
Discussion started by: crypto87
3 Replies

8. UNIX for Dummies Questions & Answers

Writing an HTML file in perl

I'm writing a perl script that writes an html file. use Tie::File; my ($dir) = @ARGV; open (HTML,">","$dir/file.html") || die $!; #-----Building HTML file--------------------------- print HTML "<!DOCTYPE html> <html> <head> <title>Output</title> <link... (3 Replies)
Discussion started by: jrymer
3 Replies

9. Shell Programming and Scripting

Need help in writing perl script

Hi, I am new to perl. I am trying to write a small perl script for search and replace in a file : ======================================================== #!/usr/bin/perl my $searchStr = "register_inst\.write_t\("; my $replaceStr = "model\.fc_block\."; open(FILE,"temp.sv") ||... (2 Replies)
Discussion started by: chettyravi
2 Replies

10. Shell Programming and Scripting

Writing xml from excel sheet .xls using perl script

Hi all. I am working on the below requirement of generating .xml file from .xls file which i have , can someone please help me or in writing the perl script for the same: The xls file format is as below which has two columns and number of rows are not fixed: Fixlet Name ... (12 Replies)
Discussion started by: omkar.jadhav
12 Replies
VCONSOLE.CONF(5)                                                   vconsole.conf                                                  VCONSOLE.CONF(5)

NAME
vconsole.conf - configuration file for the virtual console SYNOPSIS
/etc/vconsole.conf DESCRIPTION
The /etc/vconsole.conf file configures the virtual console, i.e. keyboard mapping and console font. The basic file format of the vconsole.conf is a newline-separated list environment-like shell-compatible variable assignments. It is possible to source the configuration from shell scripts, however, beyond mere variable assignments no shell features are supported, allowing applications to read the file without implementing a shell compatible execution engine. Note that the kernel command line options vconsole.keymap=, vconsole.keymap.toggle=, vconsole.font=, vconsole.font.map=, vconsole.font.unimap= may be used to override the console settings at boot. Depending on the operating system other configuration files might be checked for configuration of the virtual console as well, however only as fallback. OPTIONS
The following options are understood: KEYMAP=, KEYMAP_TOGGLE= Configures the key mapping table of for they keyboard. KEYMAP= defaults to us if not set. The KEYMAP_TOGGLE= can be used to configured a second toggle keymap and is by default unset. FONT=, FONT_MAP=, FONT_UNIMAP= Configures the console font, the console map and the unicode font map. FONT= defaults to latarcyrheb-sun16. EXAMPLE
Example 1. German keyboard and console /etc/vconsole.conf: KEYMAP=de-latin1 FONT=latarcyrheb-sun16 SEE ALSO
systemd(1), loadkeys(1), setfont(8), locale.conf(5) AUTHOR
Lennart Poettering <lennart@poettering.net> Developer systemd 10/07/2013 VCONSOLE.CONF(5)
All times are GMT -4. The time now is 08:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy