0

I have a file, abc.txt, like this on a Linux machine:

abc|yes|50c|1|pending
bcd|no|100c|2|pending
cde|yes|45c|3|pending
def|no|44c|3|pending

I have to call a script1.ksh with the 3rd field as a parameter, run all scripts in parallel and if any script failed it should update the last field from pending to FAILED/SUCCESS.

I have used while read line to extract the 3rd field into variable 'var1' from file and run the script and update 5TH FIELD FROM PENDING TO SUCCESS/FAILED. but all scripts are running serially not parallely

ksh script1.ksh 50c    
ksh script1.ksh 100c    
ksh script1.ksh 45c    
ksh script1.ksh 44c 
1
0

Just run the scripts in the background:

while IFS='|' read -r  name yno arg rest; do 
    ksh script1.ksh "$arg" && 
    status=SUCCESS || status=FAILED &&
    sed -i "/^$name|/{s/pending/$status/}" file &
done < file
4
  • my script is returning a code based on that i have to update PENDING status – ssiresha garimella Aug 10 '20 at 12:16
  • @ssireshagarimella then you should mention that in your question. We can only answer the question you actually ask, so you need to make sure all relevant detail is in the question. – terdon Aug 10 '20 at 12:47
  • @ssireshagarimella note that my code is setting "$status" to SUCCESS if ksh script1.ksh "$arg" exits with 0 status (success) and sets it to FAIL if script1.ksh exits with a non-0 status (fail). Isn't that what you want? – terdon Aug 10 '20 at 12:48
  • 2
    @ssireshagarimella please don't do this: don't extend the parameters of the question after getting an answer. Ask a single, complete question. If you then need something else, you can post a new question. But when you ask, make sure that your question includes everything you need. – terdon Aug 10 '20 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.