-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathshqueue
More file actions
executable file
·39 lines (29 loc) · 769 Bytes
/
shqueue
File metadata and controls
executable file
·39 lines (29 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
bad=$(( $$ + 1 ))
PID=$(pgrep -x shqueue |grep -v "^$bad$" |grep -vE "^$$$" )
if [ -z "$PID" ]; then
[ ! -z "$1" ] && echo Main program not running. Please start with no parameters && exit 0
function exitf {
rm $FIFO
}
trap exitf EXIT
set -e
fn=$$
FIFO=/tmp/sq$fn
mkfifo $FIFO
set +e
echo To submit commands, run this again from elsewhere.
while true; do
cat $FIFO | tee /dev/stderr | bash
#echo command done.
done
else
[ ! -z "$1" ] && pre="${*@Q} " || pre=""
[ ! -z "$1" ] && ppre="$* " || pre=""
FI=/tmp/sq$PID
[ ! -p "$FI" ] && echo not a pipe, close all shqueue instances and start again. && exit
echo Enter bash commands one per line. ^D to finish
while read -p "$ppre" -r l; do
echo "${pre}${l}" > $FI
done
fi