Sponsored Content
Top Forums Shell Programming and Scripting Parse through a txt file PERL scripting Post 302972978 by Aia on Thursday 12th of May 2016 10:43:54 AM
Old 05-12-2016
A bit simpler?

Code:
#!/usr/bin/env perl
#
use strict;
use warnings;

my $env_file = '/apps/env_data.txt';
my $uenv = shift or die "Missing uenv parameter";

open my $fh, '<', $env_file or die "Unable to open $env_file: $!";

while(<$fh>) {
    if(/^$uenv\s/) {
        my ($env, $dir, $servers) = split;
        for my $server (split /,/, $servers) {
            system "ssh $server 'cat $dir/server.properties'";
        }
        last;
    }
}

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parse the .txt file for folder name and FTP to the corrsponding folder.

Oracle procedure create files on UNIX folder on a regular basis. I need to FTP files onto windows server and place the files, based on their name, in the corresponding folders. File name is as follows: ccyymmddfoldernamefile.txt; Folder Name length could be of any size; however, the prefix and... (3 Replies)
Discussion started by: MeganP
3 Replies

2. Shell Programming and Scripting

CSV File parse help in Perl

Folks, I have a bit of an issue trying to obtain some data from a csv file using PERL. I can sort the file and remove any duplicates leaving only 4 or 5 rows containing data. My problem is that the data contained in the original file contains a lot more columns and when I try ro run this script... (13 Replies)
Discussion started by: lodey
13 Replies

3. UNIX for Dummies Questions & Answers

How to cut data block from .txt file in shell scripting

Hi All, Currently i have to write a script. For which i need to cut a block from .txt file. I know the specific word that starts the block and ends the block. Can we do it in shell scripting..? Please suggest.... (6 Replies)
Discussion started by: pank29
6 Replies

4. Shell Programming and Scripting

PERL:How to convert numeric values txt file to PACKED DECIMAL File?

Is there any way to convert numeric values txt file to PACKED DECIMAL File using PERL. Regards, Alok (1 Reply)
Discussion started by: aloktiwary
1 Replies

5. Shell Programming and Scripting

Parse file contents in perl...

Hi, I have the file like this: #Contents of file 1 are: Dec 10 12:33:44 User1 Interface: Probe Dec 10 12:33:47 uSER1 SOME DATA Dec 10 12:33:47 user1 Interface: MSGETYPE Dec 10 12:34:48 user1 ID: 10. Dec 10 12:33:55 user1 Interface: MSGTYPE Dec 10 12:33:55 user1 Id: 9 ... (1 Reply)
Discussion started by: vanitham
1 Replies

6. Shell Programming and Scripting

Perl: Parse Hex file into fields

Hi, I want to split/parse certain bits of the hex data into another field. Example: Input data is Word1: 4f72abfd Output: Parse bits (5 to 0) into field word1data1=0x00cd=205 decimal Parse bits (7 to 6) into field word1data2=0x000c=12 decimal etc. Word2: efff3d02 Parse bits (13 to... (1 Reply)
Discussion started by: morrbie
1 Replies

7. Shell Programming and Scripting

RegeX to parse data from a txt file

Hi all the experts out there, I am totally new to perl and I was given an assignment by using Perl to find the 2nd element of each line in each curly bracket which made up of 5 elements. Expected result should like this: Type: VCC Pin_name: AK32,AL32,AH21,..... Type: NC Pin_name:... (2 Replies)
Discussion started by: killbanne
2 Replies

8. Shell Programming and Scripting

Delete file2.txt from file1.txt using scripting

Hi, I`m a total newbie, well my requirement is that i have 2 files I want to identify which countries i do not currently have in db.. how can i use the grep or another command to find this file .. i want to match all-countries.txt with countries-in-db.txt so the output is equal to... (11 Replies)
Discussion started by: beanbaby
11 Replies

9. Shell Programming and Scripting

awk or perl to parse file

I have an input file attached that I am trying to parse in tab-delimanted format: The chromosomal variant column contains all the information: parse rules: 1. 4 zeros after the NC_ and the digits before the . 2. digits after the g. repeated twice separated by a tab 3. letter before the > 4.... (10 Replies)
Discussion started by: cmccabe
10 Replies

10. Linux

Scripting - parse file

Test jython (3 Replies)
Discussion started by: morpheus59
3 Replies
warnings(3pm)						 Perl Programmers Reference Guide					     warnings(3pm)

NAME
warnings - Perl pragma to control optional warnings SYNOPSIS
use warnings; no warnings; use warnings "all"; no warnings "all"; use warnings::register; if (warnings::enabled()) { warnings::warn("some warning"); } if (warnings::enabled("void")) { warnings::warn("void", "some warning"); } if (warnings::enabled($object)) { warnings::warn($object, "some warning"); } warnings::warnif("some warning"); warnings::warnif("void", "some warning"); warnings::warnif($object, "some warning"); DESCRIPTION
The "warnings" pragma is a replacement for the command line flag "-w", but the pragma is limited to the enclosing block, while the flag is global. See perllexwarn for more information. If no import list is supplied, all possible warnings are either enabled or disabled. A number of functions are provided to assist module authors. use warnings::register Creates a new warnings category with the same name as the package where the call to the pragma is used. warnings::enabled() Use the warnings category with the same name as the current package. Return TRUE if that warnings category is enabled in the calling module. Otherwise returns FALSE. warnings::enabled($category) Return TRUE if the warnings category, $category, is enabled in the calling module. Otherwise returns FALSE. warnings::enabled($object) Use the name of the class for the object reference, $object, as the warnings category. Return TRUE if that warnings category is enabled in the first scope where the object is used. Otherwise returns FALSE. warnings::fatal_enabled() Return TRUE if the warnings category with the same name as the current package has been set to FATAL in the calling module. Otherwise returns FALSE. warnings::fatal_enabled($category) Return TRUE if the warnings category $category has been set to FATAL in the calling module. Otherwise returns FALSE. warnings::fatal_enabled($object) Use the name of the class for the object reference, $object, as the warnings category. Return TRUE if that warnings category has been set to FATAL in the first scope where the object is used. Otherwise returns FALSE. warnings::warn($message) Print $message to STDERR. Use the warnings category with the same name as the current package. If that warnings category has been set to "FATAL" in the calling module then die. Otherwise return. warnings::warn($category, $message) Print $message to STDERR. If the warnings category, $category, has been set to "FATAL" in the calling module then die. Otherwise return. warnings::warn($object, $message) Print $message to STDERR. Use the name of the class for the object reference, $object, as the warnings category. If that warnings category has been set to "FATAL" in the scope where $object is first used then die. Otherwise return. warnings::warnif($message) Equivalent to: if (warnings::enabled()) { warnings::warn($message) } warnings::warnif($category, $message) Equivalent to: if (warnings::enabled($category)) { warnings::warn($category, $message) } warnings::warnif($object, $message) Equivalent to: if (warnings::enabled($object)) { warnings::warn($object, $message) } See "Pragmatic Modules" in perlmodlib and perllexwarn. perl v5.12.1 2010-04-26 warnings(3pm)
All times are GMT -4. The time now is 06:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy