Off-Topic > Off-Topic - Tiny Tux's Corner
Writing already opened file with shell
jazzbiker:
Hi GNUser,
Sure there was
--- Code: ---echo hello >&"$MY_FD"
--- End code ---
Otherwise it had no chances at all to work. Sorry for the typo.
This issue is not related to the visibility rules, bash issues syntax error. It doesn't tries to run the code. I've tried dash - the same as with bash. Only ash, only TinyCore.
jazzbiker:
The last resort is /proc/$$/fd I guess.
GNUser:
What value does MY_FD hold when it fails to work in bash? It would be interesting to see the output of echo $MY_FD
jazzbiker:
Usual file descriptor, something like 4, 5 or so.
/proc/$$/fd didn't help. :-(
Only ash, only HardTinyCore. Or TinyHardCore.
GNUser:
Maybe in bash the file descriptor must be explicitly opened with exec before it can be used (more information here).
Try reserving a number for bash to point towards your MY_FD. In my example below, let's reserve 9 for bash. So MY_FD can be 4 or 5 or whatever, but not 9.
If you run this in bash, does it work?
--- Code: ---exec 9>&"$MY_FD"
echo hello >&9
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version