debian - Keeping a bash script running along the program it has started, and sending the program input -
i'm writing simple script control process, script checks if process running, if not: executes it.
i need expand ability kill specific process instance (very 1 one script has started) after specified amount of time. problem is, once bash script executed isn't running until executed program finishes.ability pass input process useful, have graceful exit function built in service i'm running.
basically, bash script should run along process it's started, , send kill command via stdin after sleep x times out.
how forward scripted input process script has started, , how keep script running after executing process?
thanks in advance.
if want run process alongside script, need run in background:
command & pid=$!
now pid
contain pid of process started. next need way communicate process. if need send input process, use "here document":
command <<eof input more input more input var=$home eof
that gets more tricky if still need run process in background. either write input temporary file (see mktemp(1)
):
tmp=$(mktemp) cat > "$tmp" <<eof input more input more input var=$home eof command < "$tmp" & pid=$!
or can use named pipes (fifos). this article should started.
Comments
Post a Comment