Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

How to avoid running duplicated task?

$
0
0
Hi Gurus,

I have requirement to run different task based on input value. the sample file as below:
file1 (contains code need to be run)
Code:


code
aaa1
aaa2
bbb
ccc
ddd

file2 (contains all codes and job name)
Code:


code job1  job2
aaa1, job_aa1, job_a2
aaa2, job_aa2, job_a2
aaa3, job_aa3, job_a2
bbb, job_bb1, job_b2
ccc, job_cc1, job_c2
...

the code I wrote as below:
Code:


#!/bin/ksh
IFS=','
egrep -f file1 file2 > runautojob.txt
        while read feed job1 job2
        do
        if [ $1 = 'job1_cnd' ]; then
        echo "here will be autosys command to start autosys job, job name is " $job1
        elif
          [ $1 = 'job2_cnd' ]; then
        echo "here will be autosys command to start autosys job, job name is " $job2
        elif [ $1 = 'job3_cnd' ]; then
        echo "here will be autosys command to start autosys job, job name is " $job3
        fi
        done<runautojob.txt

My problem is for same prefix (example aaa), I only need to run job2 once.
for example
file1 has code as below:
aaa1
aaa2
I can only run job_a2 once, but my current script runs twice.

I changed file2 as below
Code:


code job1  job2
aaa1, job_aa1, job_a2
aaa2, job_aa2,
aaa3, job_aa3,
bbb, job_bb1, job_b2
ccc, job_cc1, job_c2
...

but if the file1 like below, it failed again.
Code:


aaa2
aaa3

anybody can give me some idea to resolve this issue?

thanks in advance.

Viewing all articles
Browse latest Browse all 16232

Latest Images

Trending Articles



Latest Images