forked from ebecheto/Skill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipcPipe2CAT.sh
executable file
·40 lines (34 loc) · 1.09 KB
/
ipcPipe2CAT.sh
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
39
#!/bin/bash
# ;; copyleft ebecheto
# copy paste from http://www.linuxjournal.com/content/using-named-pipes-fifos-bash
# while debugging load : $> ~/Skill/ipcPipe2CAT.sh | tee &
# from load("emacs_ipcPipe.il")
# ipcBeginProcess(strcat(getShellEnvVar("SKILLDIR") "/ipcPipe2CAT.sh") "" 'socketHandler)
# TODO : add $1 argument to the script to create a pipe related to the PID of the virtuoso session
# pipe=/tmp/ipcPipe2CAT_$USER_$PID
pipe=/tmp/ipcPipe2CAT_$USER
rm -f ~/.emacs2icfb.il
trap "rm -f $pipe" EXIT
if [[ ! -p $pipe ]]; then mkfifo $pipe; fi
ret=""
while true; do
if read line <$pipe; then
if [[ "$line" == 'quit' ]]; then break; fi
ret+=$line
if [[ "$ret" == *'EOF' ]]; then echo ${ret%EOF}; ret="" ;fi
echo "GOT:$line$()__$ret" #<== do not uncomment this one! otherwise : twice eval! Except is ~/.emacs2icfb is removed
fi
done
echo "Reader exiting"
## writer side :
# #!/bin/bash
# pipe=/tmp/testpipe
# if [[ ! -p $pipe ]]; then
# echo "Reader not running"
# exit 1
# fi
# if [[ "$1" ]]; then
# echo "$1" >$pipe
# else
# echo "Hello from $$" >$pipe
# fi