I have a program that output some text and then a continuous stream of characters: I want to exit this program as soon as “A” is seen in the output and I tried: However, it seems like grep doesn’t see the “A”s until the perl program exits. I also tried with sed with no luck; Any …
Is using chdir() the only way to change the working directory in Linux C?
I have been given an assignment where I have to build a custom terminal using ncurses and C, and implementation of several commands is requested. One of the commands happens to be chdir, which is meant to change the working directory, however I could not find anything more relevant in C when it comes to chang…
Unable to pass filename with space through variable to SCP command
I am trying to set the variable $file as “Unavailable Voucher’s Report_Apr-2017.txt”. It is getting set to the variable successfully. But I am getting an error when I use this variable in a SCP command inside my script. I have tried to replace the ‘ ‘(space) with ‘ ‘(…
Is there any faster way to grep the pattern or to increase the speed of while loop?
this loop is taking time because lacks of entry in main_file. Answer Your current approach is very inefficient – the whole loop could be done in a single grep, with the -f option. -F treats lines in file as strings, not patterns -x looks for exact matching line (if that is what you want) -f file reads t…
linux c: what’s the common use case of “sched_setaffinity” function? I don’t find it useful
The operating system is able to determine how to arrange difference processes/threads onto different cpu cores, the os scheduler does the work well. So when do we really need to call functions like sched_setafficity() for a process, or pthread_setaffinity_np() for a pthread? It doesn’t seem to be able t…
embedded linux/QNX – how to completely zero out flash
I have a bug related to persistent files. To determine the exact sequence of steps to reproduce the bug, I need to start out the flash disk at a known state. QUESTION Using linux/QNX commands, how do I completely zero out the entire flash disk while being Telnet’d into the system? Answer On QNX, you can…
Scanf a char pointer in Assembly
So I have a task to do, which requires from me to scanf a char* in assembly. I tried this code: It writes down first printf correctly, then it waits for input (so scanf works), but then when I enter anything -> Segmentation fault. I know, that the char* should be somehow initialized, but how can I do it fr…
pip install pickle not working – no such file or directory
Ubuntu 16.04 LTS, trying to install cpickle with pip. I’ve searched a bit, haven’t found anything useful yet. PYTHONPATH isn’t set. Error message troubleshooting steps Answer Checking on the interweb, I found this A common pattern in Python 2.x is to have one version of a module implemented …
Example device-tree-aware i2c gpio driver for Linux?
Is there a good example device-tree-aware i2c gpio driver for Linux? I’ve been looking at gpio-pcf857x but it has a header file containing struct pcf857x_platform_data which is used in board files. I am looking for a similar example, but where the i2c id is defined-in/retrieved-from the device tree. Ans…
Detailed documentation for systemd’s sd-bus
I have some project which uses libdbus for IPC. The goal is to use systemd’s sd-bus instead of libdbus. There is documentation for sd-bus (here, here and etc), but that documentation doesn’t cover all aspects of D-Bus specification implementation. I spent a lot looking for at least any detailed ex…