linux

how to connect HAL using dbus

I'm using python and dbus. What i really need is a way to get the input from my microphone into my python program and then play it back from the program. I googled a lot and it seems pyaudio might do the trick but pyaudio does not work with my ubuntu 10.04. The next option i saw was telepathy. But i don't need something that big, eithe...

Quoting in a bash variable assignment

Using the following simplified code extract: DIR='a b' mount_command="./mount.cpfs $loop $DIR -f $OPTS" sudo $mount_command Executes this line when trace is on: + sudo ./mount.cpfs /dev/loop0 a b -f -o default_permissions,allow_other,attr_timeout=0 But DIR is not quoted, and so a and b are passed as different parameters, rather tha...

how to monitor the event of mouse or keyboard

Hi, there. On Linux, is there any way in which I could shutdown the system if none action is taken by the user in some time(e.g. 30 minutes)? Thanks in advance. ...

Linux Write Function

I am writing to a text file using the write function with the file descriptor set a O_NONBLOCK. fd = open(filepath, O_RDWR | O_NONBLOCK , 0777); write(fd, string, size); The questions I have are as following: How large is the file buffer size until it is blocked? If I am using O_NONBLOCK as above, what would happen if the buffer i...

write plug-in system in c++

Good time of day! Prompt please me, where can I find information about creating a system of plug-ins in C + +? linux ...

how can i fix this invalid ELF header errror?

I installed zeromq on ubuntu 10.04 and the compilation went through without any errors. However when i try to run the python test, it results in this error: jerome@VM1:~/zeromq/pyzmq-2.0.7$ python setup.py test running test Traceback (most recent call last): File "setup.py", line 144, in <module> 'Topic :: System :: Networking' ...

Detecting VMM on linux

I'm trying to detect whether I am running on a virtual environment (vmware, virtualbox, etc) On Windows I've use several ASM but I can't use them in Linux, mainly because the code might be compiled and run on either 32 or 64 bit Linux. The following code works on both Windows 32 and 64 and was tested on VMWare, virtualbox and other virt...

shell script to capture keyboard activities

How to capture all keyboard strokes using shell script .Is there any command that is related to keyboard activities. ...

fork() as read-only shared memory

The man page on fork() states that it does not copy data pages, it maps them into the child process and puts a copy-on-write flag. Is that behavior: consistent between flavors of Linux? considered an implementation detail and therefore likely to change? I'm wondering if I can use fork() as a means to get a shared read-only memory blo...

What happens in Eclipse CDT on Linux if you press the Terminate button?

I guess some signals will be sent to the process. Some or one? If more than one in which order do they occure? And what happens if the Terminate button is pressed and if the process has forked? And what happens if the process has started other processes by system(...)? ...

Suggestions for first Linux programming project?

What would you suggest as a starting project for learning essential Linux programming skills? I don't mean just coding something in Linux, but really Linux specific stuff, in the spirit of having something tangible to show in a job interview where Linux skills are required. Also stories on how you got started with Linux coming from othe...

Setting up virtual hosts for Rails apps on Apache and Mongrel

I have a single Linux server running 3 site on Apache. Let's call them RailsApp1, RailsApp2, and SimpleApp. Both Rails applications are using Mongrel clusters. The other application is just a single HTML file. I have different Virtual Host files setup in Apache for each site, as well as mongrel_cluster.yml files for both Rails sites (cod...

printf: how to explain corrupted result

#include <stdio.h> int main(void) { double resd = 0.000116; long long resi = 0; printf("%lld %f %lld %f\n", resd, resd, resi, resi); return 0; } gives (Linux, gcc, x64) 0 0.000116 0 0.000116 ^^^^^^^^ odd, since the memory for resi is zeroed Actually, compiled with g++ it gives random r...

How can I tell if a file is text using PHP?

I'm making a search engine for our gigantic PHP codebase. Given a filepath, how can I determine with some degree of certainty whether a file is a text file, or some other type? I'd prefer not to have to resort to file extensions (like substr($filename, -3) or something silly), as this is a linux based filesystem, so anything goes as far...

Python - Make Script to Manipulate Windows File Paths but running on Linux

I have this script which processes lines containing windows file paths. However the script is running on Linux. Is there a way to change the os library to do Windows file path handling while running on linux? I was thinking something like: import os os.pathsep = '\\' (which doesn't work since os.pathsep is ; for some reason) My sc...

Any way to eliminate time lag with sshfs?

If I rsync a directory with some remote directory under an sshfs management, even if the rsync process finishes synching the directory contents, there seems to be a time lag for the sshfs directory to get updated. It is unintuitive and makes some automation process relying on sshfs contents unstable. How do I eliminate the lag? ...

compile python script in linux

So I have a python script that relies on a couple modules. Specifically pexpect and pyinoitify. I know you can compile a python script into a .exe in windows, but is there something relatively equivalent in linux? I don't care about it being a binary, I'd just like to be able to distribute my script without requiring the separate install...

linux shell script to add leading zeros to file names

I have a folder with about 1700 files. They are all named like 1.txt or 1497.txt etc. I would like to rename all the files so that all the filenames are 4 digits long. IE 23.txt becomes 0023.txt. What is a shell script that will do this? Or a related question: How do I use grep to only match lines that contain \d.txt (IE 1 digit, t...

Use Mono.NET Library in Linux

First of all, I'd like to point out that I have no experience using Mono.NET, so bear with me if the questions are silly. I'm working on an application that is written in native C++ code and works in Windows (VS2008) and Linux/Mac (gcc). There is a library that I am looking to integrate with, which is currently compiled in MS.NET (versi...

How does the shell know which directory it's in?

I have been trying to figure out how a shell knows which directory you're currently in. I know there is an environment variable $PWD but when I try changing it manually, it changes what my shell shows at the prompt but commands like ls and cd are unaffected. cd is an internal shell command so I can understand it might use info stored wi...