how to provide message queues functionality to shell

Instructional HowTo section


Locked
User avatar
wiak
Posts: 3627
Joined: Tue Dec 03, 2019 6:10 am
Location: Packing - big job
Has thanked: 56 times
Been thanked: 994 times
Contact:

how to provide message queues functionality to shell

Post by wiak »

Record copied from Puppy Programming section to WeeDogLinux HowTo info section:

misko_2083 wrote: Thu Apr 08, 2021 11:35 am

Shared memory is a method of inter-process communication (IPC),
i.e. a way of exchanging data between programs running at the same time.
One process will create an area in RAM which other processes can access;

Funny that you should mention that, which reminds me:

Long ago (2007/2008) I wrote an IPC system-level utility (in C) for accessing the likes of message queues and sockets directly from shell scripts (since shell does not itself provide such access other than fifo). Unfortunately, back then a competent Puppy dev copied my idea into a well-known Puppy system facility of the time but took the credit for the idea to himself (i.e. no acknowledgement provided). Disgraceful behaviour, typical of some even nowadays, but never mind... Nevertheless, I was not happy and as a result I discontinued publishing any later developments of that facility. However, I managed to find an old version which I have attached since it can also allow the passing of messages between subshells and parents. The version attached is called wiakmv (the larger version was simply called 'wiak' being named after my family firstnames - copied that naming idea from A.W.K.).

Usage:

I've created two scripts, script1 and script2 (attached) with the relevant wiakmv commands in them (using System V message queue here). Simply remove the dummy tar, make them executable, and then run them one after the other with separate commands:

Code: Select all

./script1
./script2

For other test you can simply run wiakmv at the commandline. For example:

Code: Select all

./wiakmv -z 4567 -s "hello world"

./wiakmv --zid 4567 --receive stdout

I used to use 'wiak' (and wiakmv) to produce simple client/server bash programs to help separate GUI from its control functionality (very efficient since wiakmv blocks when listening and only runs for a few microseconds when sending). Being a universal IPC client a practical usage was for controlling either gtkdialog or gtk-server, such as I gave an example for at following old forum link:

murga-linux.com/puppy/viewtopic.php?p=572489&sid=56b4d66099c9b3d3c0784d6a59b12b3c#572489

Note that you'll need to make that http for it to work, but I'm worried about something rockedge said about http links wrecking his forum!

Note that, despite fourteen years having gone by, I do not forget and have not forgiven the developer that used my ideas and did not give due credit. I will not therefore be resurrecting wiak or wiakmv further, but couldn't resist showing how IPC can indeed be used (no shared memory here though). I've attached the associated wiak program readme, that also includes a human readable form of its man page for those who wish to experiment with it further (only the 64bit version of wiakmv attached). All attached files need the dummy .tar removed...

Furthermore, in case anyone is interested in the C source code for old copy of earlier full wiak program, which in the non-acknowledged circumstances, will probably be the last 'wiak' program published by myself, you should be able to read it directly at gitlab link below:

https://gitlab.com/weedoglinux/wiak/-/b ... ter/wiak.c

and its header file at:

https://gitlab.com/weedoglinux/wiak/-/b ... appswiak.h

wiak
--------------------------------------------------------------------------------------------------

misko_2083 wrote: Sat Apr 10, 2021 8:42 am
wiak wrote: Fri Apr 09, 2021 1:42 am
misko_2083 wrote: Thu Apr 08, 2021 11:35 am

Shared memory is a method of inter-process communication (IPC),
i.e. a way of exchanging data between programs running at the same time.
One process will create an area in RAM which other processes can access;

Funny that you should mention that, which reminds me:

Long ago (2007/2008) I wrote an IPC system-level utility (in C) for accessing the likes of message queues and sockets directly from shell scripts (since shell does not itself provide such access other than fifo).

This is great.
I can already imagine all the use cases.
I can transfer the variables from one terminal to the next.

Code: Select all

# terminal1
./wiakmv -z 4567 -s "VAR[0]=HELLO; VAR[1]=WORLD"
# terminal2
eval $(./wiakmv -z 4567 --receive stdout)
echo ${VAR[*]}
HELLO WORLD

or with yad

Code: Select all

./wiakmv -z 4567 --receive stdout | yad --form --field "" --cycle-read &
./wiakmv -z 4567 -s "HELLO WORLD"

It's so easy.
The first client in line with the same key get's the message.

Code: Select all

./wiakmv -z 4567 --receive stdout | yad --form --field "" --cycle-read &
./wiakmv -z 4567 --receive stdout | yad --form --field "" --cycle-read &
./wiakmv -z 4567 -s "HELLO WORLD"

Thanks for making wiak and readme.txt is very well written.

By the way, I found the source code for wiakmv and wiakf 2.0.3.
It was picked up by the search web search engine once you published the code on github.

wiak wrote: Fri Apr 09, 2021 1:42 am

Unfortunately, back then a competent Puppy dev copied my idea into a well-known Puppy system facility of the time but took the credit for the idea to himself (i.e. no acknowledgement provided). Disgraceful behaviour, typical of some even nowadays, but never mind... Nevertheless, I was not happy and as a result I discontinued publishing any later developments of that facility.

Sorry to hear that. Similar happened to me. He just added a few features and removed me from copyright. https://www.linux-apps.com/p/1239435/
The old radio script that inspired @fredx181 to make yradio https://github.com/fredx181/yradio
But there is his e-mail in the header.
I e-mailed him thanks for keeping my PMRP script alive.
And got a reply:

I thought it what's a good app to start with I just wanted to add a few more features LOL simple GUI to go with it you can do anything you want with it I have other projects and the works and yes it does need a newer version of Yad to work correctly also a few patches of Yad works well with mate but not KDE as far as the notification icon goes still some more improvements can be made on it I just haven't got around to it lately

This was last year. We did some home remodeling and I have completely forgot about it.
When you mentioned your old feud it all came back to me.
I just replied:

Thanks for giving me the permission to do anything I want with it.
Maybe I can add my name back to the copyright of that script. :D

wiak wrote: Sat Apr 10, 2021 10:49 am
misko_2083 wrote: Sat Apr 10, 2021 8:42 am

By the way, I found the source code for wiakmv and wiakf 2.0.3.
It was picked up by the search web search engine once you published the code on github.

Happy to hear that. I could only find binary of wiakmv - I do remember there were other little 'wiak' programs but only had source for the bigger all-inclusive wiak (though that does contain all the source-code detail for all of course).

EDIT: Thanks (greatly). I just did a quick google search for "wiakmv github" and it came up with https://github.com/wiake/wiakapps

Attachments
wiakreadme.txt.tar
just remove dummy tar
(28.27 KiB) Downloaded 45 times
wiakmv.tar
just remove dummy tar and make executable with chmod +x
(24.15 KiB) Downloaded 41 times
script2.tar
just remove dummy tar and make executable with chmod +x
(47 Bytes) Downloaded 44 times
script1.tar
just remove dummy tar and make executable with chmod +x
(47 Bytes) Downloaded 44 times
screenshot_of_using_wiakmv.png
screenshot_of_using_wiakmv.png (44.74 KiB) Viewed 1000 times

https://www.tinylinux.info/
DOWNLOAD wd_multi for hundreds of 'distros' at your fingertips: viewtopic.php?p=99154#p99154
Αξίζει να μεταφραστεί;

User avatar
rockedge
Site Admin
Posts: 5711
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 1990 times
Been thanked: 2097 times
Contact:

Re: how to provide message queues functionality to shell

Post by rockedge »

nice!

Locked

Return to “HowTo”