I’m currently working on some shared memory stuff, but i ran into a wierd problem when it comes to pratical usage of my code.
It works like a charm i can put, and read from memory dependant on keys like a charm from bash.
But i need to implement the solution into a existing bash script, where for some reason, val=“someCommand”
it will not read the output of the C code.
I can concat a “a” and the result is “a”, it just completely ignores the result of the C-legacy output.
Anyone ever tried something like this?
I’ve tried piping, and all that jazz.
It should be noted i am fairly new to C and am still learning, so feel free to rip me about being a newbie
The syntax for command substitution in bash (to replace a command with its output) is $(command)
. So you would need val=$(someCommand)
or perhaps val="$(someCommand)"
depending on how you want bash to treat your output.
Got it working, turns out it was user rights to read/write to the shared memory space.
For some reason the output i was given, even when using command substitution was not the error.
Just the output from reading the memory space, but since i was denied access it just read empty/nothing.
it didn’t dawn on me what was going on until i used $(someCommand 2<&1), which returned a access denied’ish message.