Skip to content
Advertisement

Tag: stdin

Bash | pipe to bash function

In the attempt to pipe to a Bash function, I wrote this: However, in another context I am receiving the correct output plus this error message: “Segmentation fault (core dumped)”. Trying to debug it I ask if there is something wrong the way I am writing the code inside the function in order to get STDIN. Thanks a lot. Answer

Using variables as the input to command

I’ve scoured various message boards to understand why I can’t use a variable as input to a command in certain scenarios. Is it a STDIN issue/limitation? Why does using echo and here strings fix the problem? For example, As you can see I get the error… ‘File name too long’ Now, I am able to get this to work by

Why cat 0>file doesn’t work

In Unix, I know that 0 1 and 2 represent stdin stdout and stderr. As my understanding, the command cat meaning “concatenate” can concatenate different files. For example, cat file>&1 can concatenate the file and the stdout and the arrow means the redirection from the fileto the stdout, so we can see the content of the file from the terminal

Execute a command in another terminal via /dev/pts

I have a terminal that uses STDIN 3 (/proc/xxxx/fd/0 -> /dev/pts/3) So if (in another terminal) I do: The command is shown in my first (pts/3) terminal, but the command is not executed. And if (in this terminal pts/3) I’m in a program waiting for some data from stdin, the data is written on screen but the program does not

Nonblocking Get Character

Platform: Linux 3.2.0 x86 (Debian 7) Compiler: GCC 4.7.2 (Debian 4.7.2-5) I am writing a function that reads a single character from stdin if a character is already present in stdin. If stdin is empty the function is suppose to do nothing and return -1. I googled nonblocking input and was pointed to poll() or select(). First I tried to

Flush/Clear System.in (stdin) before reading

At work, we have 5 RFID readers attached to a PC running Linux. The readers are all recognized as keyboards and send their input (what they read form the Chip) as an key-input-event sequence. To be able to tell which reader send what sequence, I’m doing a raw-read over /dev/input/XX and get their input this way. The problem with this

Compress files while reading data from STDIN

Is it possible to compress (create a compressed archive) data while reading from stdin on Linux? Answer Yes, use gzip for this. The best way is to read data as input and redirect the compressed to output file i.e. cat test.csv will send the data as stdout and using pipe-sign gzip will read that data as stdin. Make sure to

Advertisement