mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-19 20:14:17 +02:00
Add example scripts for socket interaction
This commit is contained in:
parent
8660346f76
commit
e46a32ab43
3 changed files with 60 additions and 0 deletions
16
example_scripts/cb_script_header.sh
Normal file
16
example_scripts/cb_script_header.sh
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
named_pipe_send="$(mktemp -u)"
|
||||
named_pipe_recv="$(mktemp -u)"
|
||||
mkfifo "${named_pipe_send}"
|
||||
mkfifo "${named_pipe_recv}"
|
||||
nc -U "${CAGEBREAK_SOCKET}" < "${named_pipe_send}" > "${named_pipe_recv}"&
|
||||
# The file descriptor 3 is set up to send commands to cagebreak and file
|
||||
# descriptor 4 can be used to read events. Notice that events will pile up in
|
||||
# file descriptor 4, so it is a good idea to continuously read from it or to
|
||||
# clear it before starting a new transaction.
|
||||
exec 3>"${named_pipe_send}"
|
||||
exec 4<"${named_pipe_recv}"
|
||||
# When the script exits, the os will clean up the pipe
|
||||
rm "${named_pipe_recv}"
|
||||
rm "${named_pipe_send}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue