Sponsored Content
Full Discussion: Parsing a control file loop
Top Forums Shell Programming and Scripting Parsing a control file loop Post 303017312 by Chubler_XL on Sunday 13th of May 2018 10:27:22 PM
Old 05-13-2018
You might have more success in using awk in filter your control file.

Slight change in format of control file:

Code:
RHEL apple
    echo apple
RHEL bravo 
    ls -l bravo*
RHEL church 
    chmod church.txt

SUSE drive
    chown user1 drive.txt
SUSE eagle 
    echo "eagle flies"
SUSE feather
    ls -l feather*

HP-UX google
    sed 's/^Google.*$/&\
ACTION: go to www.google.com/' google.txt

HP-UX heartache
    ls -l heartache.txt* | awk '{ print $9 }'


I set the variable CGRP to be the 2nd param on your control lines. The awk output could be piped to a shell once your happy it's looking OK:

Code:
OPER_SYS="$1"
  
case $OPER_SYS in
    RHEL|SUSE|HP-UX)
    ;;
    *)  echo "Usage $0 [RHEL|SUSE|HP-UX]" >&2
        exit 2
    ;;
esac

awk -v SYS=$OPER_SYS '
  NF==2 && $1==SYS { exec = 1 ; print "CGRP="$2 ; next }
  NF==2 && $1 ~ "(RHEL|SUSE|HP-UX)" { exec = 0 }
  exec { print }' control


example:
Code:
$ ./do_control HPUX
Usage ./do_control [RHEL|SUSE|HP-UX]

$ ./do_control HP-UX
CGRP=google
    sed 's/^Google.*$/&\
ACTION: go to www.google.com/' google.txt

CGRP=heartache
    ls -l heartache.txt* | awk '{ print $9 }'

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sending control c in the loop

I want to go through the list of items and run it. while running it, some of them will have either >there is no response # and then end it... so that it can go to next item OR >there is response # but in order to break out of it, u need to do Control c. How do you send control... (6 Replies)
Discussion started by: hankooknara
6 Replies

2. Shell Programming and Scripting

find command in while loop - how to get control when no files found?

I have the following statement in script: find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do ... done When there are no files located by the find comand it returns: "find: bad status-- /home/rnitcher/test/....." to the command line How do I get control in... (3 Replies)
Discussion started by: mavsman
3 Replies

3. Shell Programming and Scripting

for loop control

Hi, I have taken a piece of code from a book, which is working as per the specification. The code.... for entry in * do if then echo $entry fi done The sub-directories present in the current directory will be displayed while executing. ... (3 Replies)
Discussion started by: saravanakumar
3 Replies

4. Shell Programming and Scripting

Control Not Coming Out Of While Loop

I have an empty .gz file in archival directory. And I am redirecting to a dat file. My while loop is not getting ended. I need the solution. cnt=0 while read line do cnt=`expr $cnt + 1` echo "$ARCH_DIR/$line.gz" >> $DATA_DIR/$FILE_LIST_FILE_FEB FILE_NAMES=${FILE_NAMES}"... (2 Replies)
Discussion started by: vinodh1978
2 Replies

5. Shell Programming and Scripting

Parsing of file for Report Generation (String parsing and splitting)

Hey guys, I have this file generated by me... i want to create some HTML output from it. The problem is that i am really confused about how do I go about reading the file. The file is in the following format: TID1 Name1 ATime=xx AResult=yyy AExpected=yyy BTime=xx BResult=yyy... (8 Replies)
Discussion started by: umar.shaikh
8 Replies

6. UNIX for Dummies Questions & Answers

For loop control with two variables in csh shell

Hi All How can i control for loop with two different variables in csh shell Regards Nikhil (1 Reply)
Discussion started by: Nikhilindurkar
1 Replies

7. Shell Programming and Scripting

Loop exit control

Hi I would like to exit the loop below on <Enter> even if it sleeps. Is it possible? while true do my_procedure; sleep 60 done Thanks (7 Replies)
Discussion started by: zam
7 Replies

8. Shell Programming and Scripting

Check and control params in parsing file

Hello, I would like to control and check the right parameters $1 must have 4 alphabetics digits among eora qora pora fora $2 must have 2 numerics digits 00 to 11 $3 must have 2 numerics digits 00 to 59 $4 must have 10 characters alpha numerics as 2013-02-26 For example : In case 5) if i... (1 Reply)
Discussion started by: amazigh42
1 Replies

9. Shell Programming and Scripting

Check and control params in parsing file

Hello, I would like to control and check the right parameters $1 must have 4 alphabetics digits among eora qora pora fora $2 must have 2 numerics digits 00 to 11 $3 must have 2 numerics digits 00 to 59 $4 must have 10 characters alpha numerics as 2013-02-26 For example : In case 5) if i... (15 Replies)
Discussion started by: amazigh42
15 Replies

10. Shell Programming and Scripting

Parsing log file and print latest number in loop

Hello All, I have an awk script which parses my log file and prints number grepping from a specific line/pattern, now i have to come with a shell script to continue reading the log untill the job is completed, which i would know while reading session log untill process encounters a final... (1 Reply)
Discussion started by: Ariean
1 Replies
subscription-manager-gui(8)				       Subscription Manager				       subscription-manager-gui(8)

NAME
subscription-manager-gui - Launches the UI client of the Subscription Manager. SYNOPSIS
subscription-manager-gui [--register] DESCRIPTION
subscription-manager-gui opens the local client tool to manage subscriptions and installed products on Red Hat Enterprise Linux systems. The same tasks that can be performed by invoking subscription-manager can be performed in the GUI, including registering systems with a subscription management service, applying and removing subscriptions, and viewing the subscription status of installed products. The Subscription Manager UI can also be opened by selecting the Red Hat Subscription Manager item from the Applications > System Tools menu in RHEL 5.x or the System > Administration menu in RHEL 6.x. OPTIONS
--register If a system has not yet been registered, then the GUI registration page can be opened immediately, as the Subscription Manager GUI comes up. This is only relevant for unregistered systems; if this is used after a system is registered, the option is ignored. REFERENCES
For procedures and tasks that can be performed in the Subscription Manager UI, check the Gnome help files (by pressing <F1>) or refer to the RHEL Subscription Management Guide at <https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Subscription_Management/1.0/html/Sub- scription_Management_Guide/index.html>. ASSOCIATED FILES
* /usr/sbin/subscription-manager-gui * /usr/sbin/subscription-manager * /etc/rhsm/rhsm.conf BUGS
This client is part of Red Hat Subscription Manager. To file bugs against this client, go to https://bugzilla.redhat.com, and select Red Hat > Red Hat Enterprise Linux > subscription-manager. AUTHORS
Deon Lackey, <dlackey@redhat.com>. COPYRIGHT
Copyright (c) 2010-2012 Red Hat, Inc. This is licensed under the GNU General Public License, version 2 (GPLv2). A copy of this license is available at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. version 1.2 December 18, 2012 subscription-manager-gui(8)
All times are GMT -4. The time now is 02:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy