Skip to content

Commit d31c237

Browse files
committed
command launcher
1 parent da941eb commit d31c237

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/readoutCommandLauncher.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
# wrapper script to execute commands from stdin
3+
# invoked by o2-readout-exe
4+
# if launched without argument, read commands from stdin line by line
5+
6+
# ensure log output not going to stdout
7+
unset O2_INFOLOGGER_MODE
8+
9+
LOG="/opt/o2-InfoLogger/bin/o2-infologger-log -oFacility=readout -oLevel=11 -oErrorCode=3013"
10+
CMD="'$*'"
11+
12+
if [ "$1" == "" ]; then
13+
14+
$LOG "Starting command launcher"
15+
while read line
16+
do
17+
$LOG "Executing command $line"
18+
eval $line 2>&1 | $LOG -x -oSeverity=Debug
19+
20+
if [ 0 -eq ${PIPESTATUS[0]} ]; then
21+
echo "ok"
22+
$LOG "Command ok"
23+
else
24+
echo "error"
25+
$LOG -oSeverity=Error "Command error"
26+
fi
27+
done
28+
$LOG "Exiting command launcher"
29+
exit 0
30+
31+
else
32+
33+
$LOG "Executing command $CMD"
34+
$@ 2>&1 | $LOG -x -oSeverity=Debug
35+
36+
if [ 0 -eq ${PIPESTATUS[0]} ]; then
37+
echo "ok"
38+
$LOG "Command ok"
39+
exit 0
40+
else
41+
echo "error"
42+
$LOG -oSeverity=Error "Command error"
43+
exit 1
44+
fi
45+
46+
fi
47+

0 commit comments

Comments
 (0)