Sample Header Ad - 728x90

How to run eval with lockf command?

0 votes
2 answers
191 views
I have a command which I run via eval as shown below.
#! /bin/sh

readonly scr="MYENV=1 sh /tmp/scr.sh"

eval ${scr} -a 1 -b 2
Now I want to run the scr script with lockf utility, so I made the following changes:
#! /bin/sh

readonly scr="MYENV=1 sh /tmp/scr.sh"

lockf -k /tmp/f.lock eval ${scr} -a 1 -b 2
This throws the following error:
lockf: eval: No such file or directory
Basically the limitation is the MYENV=1 which needs to be exported while running the command (thus the use of eval). I'm a beginner in shell programming and am unsure on how to get around this. How do I make this work?
Asked by Rahul Bharadwaj (235 rep)
Aug 31, 2021, 04:20 AM
Last activity: Aug 31, 2021, 07:44 AM