almahdi <budikus...@gmail.com> writes: > How do we intercept and redirect file saving or output to stdout directly in > bash, just like e.g > > xkbcomp $DISPLAY > > will output and generated a file, but what needed is to put it directly to > stream of stdout which will be piped once. ... > $ xkbcomp $DISPLAY /dev/stdout > Error: Cannot open "/dev/stdout" to write keyboard description > Exiting
Normally, that should work. But I get the same error message as you do. I did a trace on xkbcom and I see at the end: open("/dev/stdout", O_WRONLY|O_CREAT|O_EXCL, 0666) = -1 EEXIST (File exists) write(2, "Error: ", 18Error: ) = 18 write(2, "Cannot open \"/dev/stdout\" to wri"..., 56Cannot open "/dev/stdout" to write keyboard description ) = 56 The open() is done with the O_EXCL flag. Reading the manual page open(2), I see that O_EXCL requires that the open() call creates the file. It's not clear why xkbcomp has this behavior, but it seems likely that this is done for a specific reason. So you will have to ask whoever maintains it. I don't see any option that overrides this behavior. However, as Robert said, many programs handle an argument "-" specially as a reference to stdin or stdout. And it turns out that (my version of) xkbcomp does so: $ xkbcomp $DISPLAY - xkb_keymap { xkb_keycodes "evdev+aliases(qwerty)" { minimum = 8; maximum = 255; <ESC> = 9; <AE01> = 10; ... Dale