Reputation: 843
I have a bash CGI logging connections to my server, I want to that when a new connection is requested/stablised/served this script passes an argument/variable to another script running in the background? is this possible? how can i do this?
I have tried environmental variables but this will only work in the same shell and I cannot be sure both will be running on the same shell. I've tried writing to a file but how could i know when the file has been edited thus allow the second script to execute the command.
I'm starting to get crazy, this must be possible I cannot believe to "programs" cannot share information... :O
maybe i'm taking the wrong approach, can someone please advise?
Thanks, Marco P.
Upvotes: 0
Views: 76
Reputation: 246799
named pipes might be one way, although it is blocking:
setup:
mkfifo /path/to/named/pipe
cgi script:
echo "some data" > /path/to/named/pipe # blocks until other script consumes!
background script:
while :; do
read data < /path/to/named/pipe # blocks until cgi script produces!
do_stuff_with "$data"
done
Upvotes: 2