linux

How to play sound in Python WITHOUT interrupting music/other sounds from playing

I'm working on a timer in python which sounds a chime when the waiting time is over. I use the following code: from wave import open as wave_open from ossaudiodev import open as oss_open def _play_chime(): """ Play a sound file once. """ sound_file = wave_open('chime.wav','rb') (nc,sw,fr,nf,comptype, compname) = so...

PHP - writing data to a file with 777 permission

I have a .TXT file in a web-server with the permission as 777. So what are the changes that others might be able to edit the content of this file? The content is not much - just a number. Someone seems to have been tinkering with this file as the number vanished the other day! No one else except me has the FTP password. So I was wonderi...

About the composition of Linux command

Assuming: the path of file f is ~/f "which f" shows "~/f", Then, which f | cat shows ~/f. So cat here is applied to the quotation of ~/f, which is different with cat ~/f. My question is: how I could use one command composed of which and cat to achieve the result of cat ~/f? When I don't know the result of which f in advance, using ...

What is the best way to prevent out of memory (OOM) freezes on Linux?

Is there a way to make the OOM killer work and prevent Linux from freezing? I've been running Java and C# applications, where any memory allocated is usually used, and (if I'm understanding them right) overcommits are causing the machine to freeze. Right now, as a temporary solution, I added, vm.overcommit_memory = 2 vm.overcommit_ratio...

How to create a RPM build for opensuse 11.2 form netatalk 2.0.5

Is there someone who knows how to create a RPM from netatalk 2.0.5. Or better has a URL to a RPM? I aske this because so fare I know there are no RPM's for opensuse 11.2 (or suse). Thankyou, Ivo Trompert ...

How to output awk result to file

Hi I am trying to output 'awk' result to file in my script, with no success. Using '>' does not work, why? for a in $(find $OUPUT_DIR/ -maxdepth 1 -mindepth 1 -type d -printf "%P\n") do echo $a is a directory awk -F, '{ if ($10 == '"$a"') print $0 }' $OUPUT_DIR/CDRNOutput_${CDR_DATE}.csv > $OUPUT_DIR/$a/CDR-${CDR_DATE}.csv done...

Xerces C++ - Load, read and save, alternatives?

I'm searching for a tutorial to load a XML file, read it, change it and finally save it with C++. I'm using Linux Ubuntu and tried to use Xerces. With Google and much time, I could only load an XML File: #include <xercesc/parsers/XercesDOMParser.hpp> #include <xercesc/dom/DOM.hpp> #include <xercesc/sax/HandlerBase.hpp> #include <xercesc...

Embedding an icon in a Linux executable

I have written an application in Java and succesfully compiled it using gcj. In (X)ubuntu's File Manager, my application appears with the default Linux executable icon, which I would like to replace with my own: I have seen that other applications display a custom icon as the executable, such as Firefox, but have no idea how to appr...

Outliers during Performance Evaluation

Hello all, I am trying to do some performance measurements using Intels RDTSC, and it is quite odd the variations I get during different testruns. In most cases my benchmark in C needs 3000000 Mio cycles, however, exactly the same execution can in some cases take 5000000, almost double as much. I tried to have no intense workloads runni...

How to check which program runs inside gnome-terminal

I want to write a program which prints the current focused window name and if it is a gnome-terminal, then prints out the running program inside the current gnome-terminal tab (for example vim, if a vim session is running). To get the currently focused window name, I used: xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" ...

Linux - Is there a way to have a simple static library that contains resources?

I am trying to figure out a way of embedding a resource into a static library for linking with C source using the gcc toolchain. The equivalent of a Windows DLL in which resources are embedded. Can this be done with a linux static library? In short, would for example, doing this cat someresourcedata.txt > mylib.a and to be able to lin...

I need to link C program on a shared object with no section headers

I've written an interface to the code generator that lets me produce shared objects. Though I do not want o implement support for section header table because that's where the majority complexity of ELF file format remains in. GNU ld uses section headers for linking against shared objects. This means that when I try to put gcc link agai...

gcc - significance of -pthread flag when compiling

In various multi threaded C and C++ projects I've seen the -pthread flag applied to both the compiling and linking stage while others don't use it at all and just pass -lpthread to the linking stage. Is there any danger not compiling and linking with the -pthread flag - i.e. what does -pthread actully do ? I'm primarly interrested in li...

Rearrange columns using cut

Hi, I am having a file in the following format Column1 Column2 str1 1 str2 2 str3 3 I want the columns to be rearranged. I tried below command cut -f2,1 file.txt The command doesn't reorder the columns. Any idea why its not working? Thank you. ...

Problem compiling Linux source

I am trying to compile Linux source but always get qt missing, here is a output [root@localhost linux-2.6.32.5]# yum install qt3 Loaded plugins: refresh-packagekit Setting up Install Process Package qt3-3.3.8b-25.fc11.i586 already installed and latest version Nothing to do [root@localhost linux-2.6.32.5]# make xconfig CHECK qt * * U...

Is it recommend to trap SIGPIPE in bash script?

Hi, I have a problem while executing a bash script from C++ using the system call command. The script catch a SIGPIPE signal and exit with ret code 141. This problem has started to appear only in the last release of my code. My Questions are as follows: 1) Why does this SIGPIPE occur now and didn't occur before? 2) Is it safe to ignor...

Kill/Yank (cut/paste) in ZSH

I use zsh and have the Emacs keybindings set up for it. I'd love to have it replicate all my regular Emacs text manipulation commands. One which I miss is the Kill/Yank keys. It would be nice if I could select text (using C-SPC - this works) and then do something like a kill-region (C-w - This right now deletes the previous word). The ya...

How to get Shared Object in Shared Memory

Our app depends on an external, 3rd party-supplied configuration (including custom driving/decision making functions) loadable as .so file. Independently, it cooperates with external CGI modules using a chunk of shared memory, where almost all of its volatile state is kept, so that the external modules can read it and modify it where ap...

Variable Context Switching Time

Hi there, I just made some changes to the context switch routine of Linux. I am facing now the following dilemma: The context switching time is no longer deterministic, i.e. the execution time varies on the applications that are switched out. I am wondering now what could be the negative implactions of such a behaviour. One potential pi...

How to synchronize files in load balanced instances?

One of the challenges that we face during deployments on multiple load balanced instances is – the risk of not deploying the latest code base to one or more load balanced instances. Idea is to use only one instance for direct deployment and entrust sync up to a script that syncs up selected list of folders to the other load balanced in...