I’ve already asked similar question many times, but still can’t find appropriate solution. I have and external function, that could run in some cases very long. I want to interrupt it after, say, 30 seconds. How do I do that? Threads are good, but I can’t stope them (i don’t have acces…
Tag: linux
Get storage device block size from name/descriptor of a file on that device
Suppose that I have file name or an open file decriptor for a text file that resides on a storage device (hard disk, usb flash, dvd, etc.). How can I get block size of that device from file name/descriptor in Linux programmatically in C. I know about ioctl system call, but it accepts an open descriptor for de…
segfault when using shout-python inside a thread
Recently a machine was upgraded/reinstalled from an older Ubuntu version to the most recent Debian version. Since then, I get a segfault in an application I wrote which sends data to an icecast daemon. After some searching, I focused it down to threading. As soon as I call shout.send from inside a thread, I g…
Is there a way to ‘store’ Sudo temporarily
I’m quite new to Linux. I remember using a tutorial were you were able to declare your sudo (+password) at the start and then use terminal without having to do sudo or import your password again. I.e. Sudo yum-get update -> yum-get update. Sorry if this is a very obvious question, I honestly don̵…
Using awk to trim away parts of a text file outside 2 patterns
I’d like an elegant awk solution to edit the lines in a file. So far I’ve only managed to complete the task using 2 sed commands and 1 awk command. Each file is composed of a header of indeterminate length, followed by the data I want to capture, then a footer which always starts with the same str…
python: numpy runs script twice
when I import numpy to my python script, the script is executed twice. Can someone tell me how I can stop this, since everything in my script takes twice as long? Here’s an example: And the output is: So, is my script first executed with normal python and then with numpy again? Maybe I should say that I…
How to send BACKSPACE in expect?
I’m trying to automatize some tool, and I have Problem is that by default in prompt is added last product number , for example When I run my expect script in prom is added So how I can tell in except that send BACKSPACE (delete) default product number add set only new one in prompt for example , somethi…
How can I create a patch to delete a folder and create new folder using diff?
For example I have two directories say old and new. The directory old has a sub-directory abc and the directory new has a sub-directory cde. I tried creating patch by using I got following output in file.patch: and when I tried to patch the file I got following error: When I try to create patch by using: I ge…
Linux: Stopping tar command?
Uh I badly messed up today, I was going to backup my whole website folder (public_html) and didn’t realize that it was 24GB, now it’s eating up disk usage and I have no idea how to stop it. The command I used was: I deleted the existing backup.tar.gz from the directory but the command is still run…
How can I resolve Windows vs Linux properties file paths?
I have a java project on a Windows box which builds successfully and all tests pass locally. This project is then checked in and built with Jenkins on a Linux box. The problem I am having is related to path issues in my properties file which is used for running tests. I point to a resources dir for part of