Sponsored Content
Full Discussion: Parsing a control file loop
Top Forums Shell Programming and Scripting Parsing a control file loop Post 303017313 by The Gamemaster on Monday 14th of May 2018 12:42:39 AM
Old 05-14-2018
I apologize to everyone helping out here, I posted such a bad sample of what I'm actually doing. Anyway this one below is much closer to what I'm actually doing.

Code:
RHEL:syslogd:"sed -i 's/^syslogd.*$/&\n*ACTION \/etc\/init.d\/syslog start/' $CFG_DIR/ps_mon.cfg"
RHEL:ntpd:"sed -i 's/^ntpd.*$/&\n*ACTION \/etc\/init.d\/ntpd start/' $CFG_DIR/ps_mon.cfg"
RHEL:scopeux:"sed -i 's/^scopeux.*$/&\n*ACTION \/opt\/perf\/bin\/ovpa start all/' $CFG_DIR/ps_mon.cfg"

SUSE:cron:"sed -i 's/^cron.*$/&\n*ACTION \/etc\/init.d\/cron start/' $CFG_DIR/ps_mon.cfg"
SUSE:scopeux:"sed -i 's/^scopeux.*$/&\n*ACTION \/opt\/perf\/bin\/ovpa start all/' $CFG_DIR/ps_mon.cfg"
SUSE:midaemon:"sed -i 's/^midaemon.*$/&\n*ACTION \/opt\/perf\/bin\/ovpa start all/' $CFG_DIR/ps_mon.cfg"

HP-UX:scopeux:"find $CFG_DIR -name "ps_mon.cfg" | while IFS= read -r file; do sed 's/^scopeux.*$/&@*ACTION \/opt\/perf\/bin\/ovpa start all/' "$file" | tr '@' '\n' > tmp && mv tmp "$file"; done"
HP-UX:midaemon:"find $CFG_DIR -name "ps_mon.cfg" | while IFS= read -r file; do sed 's/^midaemon.*$/&@*ACTION \/opt\/perf\/bin\/ovpa start all/' "$file" | tr '@' '\n' > tmp && mv tmp "$file"; done"
HP-UX:perfalarm:"find $CFG_DIR -name "ps_mon.cfg" | while IFS= read -r file; do sed 's/^perfalarm.*$/&@*ACTION \/opt\/perf\/bin\/ovpa start all/' "$file" | tr '@' '\n' > tmp && mv tmp "$file"; done"

I've just found a way on how to deal with \n special character in HP-UX thus the above. Anyway, I replaced the delimiters with ":" because spaces inside the commands in quotes are problematic. When I try the code below in HP-UX:

Code:
for line in `cat sample.ctl`
do
echo $line
done

I get the output below:

Code:
HP-UX:scopeux:"find
$CFG_DIR
-name
"ps_mon.cfg"
|
while
IFS=
read
-r
file;
do
sed
's/^scopeux.*$/&@*ACTION
\/opt\/perf\/bin\/ovpa
start
all/'
"$file"
|
tr
'@'
'
'
>
tmp
&&
mv
tmp
"$file";
done"

That's why I can't use awk to assign variables. The only way I've seen so far to solve this is to replace the spaces with another character, like a comma, then remove the comma with sed substitution when I assign the command on a variable. Too much of a hassle. If you have a way to simplify this, please let me know.

Thanks for the help so far.

Last edited by The Gamemaster; 05-14-2018 at 02:52 AM..
 

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
pkgproto(1)							   User Commands						       pkgproto(1)

NAME
pkgproto - generate prototype file entries for input to pkgmk command SYNOPSIS
pkgproto [-i] [-c class] [path1] pkgproto [-i] [-c class] [path1=path2...] DESCRIPTION
pkgproto scans the indicated paths and generates prototype(4) file entries that may be used as input to the pkgmk(1) command. If no paths are specified on the command line, standard input is assumed to be a list of paths. If the pathname listed on the command line is a directory, the contents of the directory is searched. However, if input is read from stdin, a directory specified as a pathname will not be searched. OPTIONS
-i Ignores symbolic links and records the paths as ftype=f (a file) versus ftype=s (symbolic link). -c class Maps the class of all paths to class. OPERANDS
path1 Pathname where objects are located. path2 Pathname which should be substituted on output for path1. EXAMPLES
Example 1: Examples of the use of pkgproto.1. The following two examples show uses of pkgproto and a partial listing of the output produced. Example 1: example% pkgproto /bin=bin /usr/bin=usrbin /etc=etc f none bin/sed=/bin/sed 0775 bin bin f none bin/sh=/bin/sh 0755 bin daemon f none bin/sort=/bin/sort 0755 bin bin f none usrbin/sdb=/usr/bin/sdb 0775 bin bin f none usrbin/shl=/usr/bin/shl 4755 bin bin d none etc/master.d 0755 root daemon f none etc/master.d/kernel=/etc/master.d/kernel 0644 root daemon f none etc/rc=/etc/rc 0744 root daemon Example 2: example% find / -type d -print | pkgproto d none / 755 root root d none /bin 755 bin bin d none /usr 755 root root d none /usr/bin 775 bin bin d none /etc 755 root root d none /tmp 777 root root EXIT STATUS
0 Successful completion. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
pkgmk(1), pkgparam(1), pkgtrans(1), prototype(4), attributes(5) Application Packaging Developer's Guide NOTES
By default, pkgproto creates symbolic link entries for any symbolic link encountered (ftype=s). When you use the -i option, pkgproto cre- ates a file entry for symbolic links (ftype=f). The prototype(4) file would have to be edited to assign such file types as v (volatile), e (editable), or x (exclusive directory). pkgproto detects linked files. If multiple files are linked together, the first path encountered is considered the source of the link. By default, pkgproto prints prototype entries on the standard output. However, the output should be saved in a file (named Prototype or prototype, for convenience) to be used as input to the pkgmk(1) command. SunOS 5.10 6 Nov 2000 pkgproto(1)
All times are GMT -4. The time now is 06:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy