linux

How can I write a here doc to a file in bash script?

How can I write a here document to a file in bash script? ...

Parsing line with delimiter in Python

I have lines of data which I want to parse. The data looks like this: a score=216 expect=1.05e-06 a score=180 expect=0.0394 What I want to do is to have a subroutine that parse them and return 2 values (score and expect) for each line. However this function of mine doesn't seem to work: def scoreEvalFromMaf(mafLines): for word i...

Keyboard hooking for Bengali Phonetic keyboard

As an academic project we are trying to make a software for Linux that will be used to write Bengali(Phonetic).To do this we need keyboard hooking in Linux. But i have found there's not so much resource available on keyboard hooking. Is there any API in Linux for hooking? Is there any good documentation for hooking in Linux? ...

appending text to all files that starts with a string

How do I append a string to all the files in a directory that starts with a particular string? I tried, cat mysig >> F* But instead of appending contents of mysig to all files starting with F, it creates a file named "F*". Obviously wildcard doesn't seem to work. Any alternatives? Thanks in advance. Edit: Also how do I delete this n...

grep options (unix)

hello everyone, can You explain please, can grep pick rows if at least one element from the list appeared, for exmaple grep "hello world" file1 grep must give me all rows which have or word hello or world or both of them, thanks in advance ...

How to restart C daemon program in Linux after receiving SIGHUP signal

Hello Can anybody please post some example code on how I can reread a configuration file and restart my daemon after the daemon receives a SIGHUP signal. The daemon is a user space program written in C on Linux and is not started by inetd. ...

Updating a single file in a compressed tar

Given a compressed archive file such as application.tar.gz which has a folder application/x/y/z.jar among others, I'd like to be able to take my most recent version of z.jar and update/refresh the archive with it. Is there a way to do this other than something like the following? tar -xzf application.tar.gz cp ~/myupdatedfolder/z.jar a...

Printing values in special format using printf

I need to print the following values with printf as the follwoing around like this: printf "[`date +%d"/"%b"/"%G"-"%T`] [WARN] $PARAM1 $PARAM2 $PARAM3 The required output: [02/Jun/2010-11:08:42] [WARN] val1....val2...val3 the gap between val1 to val2 and from val2 to val3 must be const gap not depend the length of the values ...

Problem with "write" function in linux

I am trying to write 2 server/client programs under Linux, in which they communicate through named pipes. The problem is that sometimes when I try to write from the server into a pipe that doesn't exist anymore (the client has stopped), I get a "Resource temporarily unavailable" error and the server stops completely. I understand that ...

How to auto-create a makefile in the same directory as i create a Latex file?

When I create a .tex file using vim I get a nice template from having autocmd BufNewFile *.tex 0r $HOME/.vim/templates/skeleton.tex in my .vimrc. I also have a makefile-template in my home directory, but this one I have to manually copy to where the .tex file is. In a Linux environment, how can I auto-copy or auto-generate the makefil...

script to delete all /n number of lines starting from a word except last line

how to delete all lines below a word except last line in a file. suppose i have a file which contains | 02/04/2010 07:24:20 | 20-24 | 26 | 13 | 2.60 | | 02/04/2010 07:24:25 | 25-29 | 6 | 3 | 0.60 | +---------------------+-------+------------+----------+-------------+ 02-04-2010-07:24 --- ER...

PHP find if file data is an image

Imagine I have some file data in a variable $data. I need to determine whether it is an image or not. No need for details such as corrupt images etc. Firs thought would be getting the file mime type by looking at the magic number and then see whether "image" is in the mime type. No such luck, even if I have a "file extension to mime ty...

Navigating multiples files vi editor

According to http://www.lagmonster.org/docs/vi2.html the command :p would make vi go to the previous file. Unfortunately, this isn't working for me. However :n works and goes to the next page. What should I use to go to the previous file? For :p I get the message, Hit Return to continue and it stays in the same page. Thanks. Edit: I a...

Help understanding output of "netstat -s", "ethtool" and "tc -s -d qdisc" on Linux

While trying to debug a network problem, I've run into some difficulties understanding the output of some diagnostic tools. Context: distributed application over 7 nodes on a Linux cluster. 1GB ethernet, sustained data rate while on operation: 600Mbits per node (up+downstream). The symptom is a blocked TCP connection: sender blocks on a...

C++: Code assistance in Netbeans on Linux

Hi, My IDE (NetBeans) thinks this is wrong code, but it compiles correct: std::cout << "i = " << i << std::endl; std::cout << add(5, 7) << std::endl; std::string test = "Boe"; std::cout << test << std::endl; He always says: unable to resolve identifier .... (.... = cout, endl, string); So I think it has something to do with the code...

Qt Library version required for porting phoneme MR4

Hello, I am porting phoneme feature mr4 for my linux-arm device in qt.As all the functions reuired for j2me porting are already written in QT, I want to use appropriate qt library. So Please can anyone guide me about which version of qt/embedded will i require for this port. Thanks and Regards, Aditya ...

bash getting a fd of a pipe

Hi, Why does the following not work? exec 3<|cat $0 The idea is to get file-descriptor (3) of a pipe (| cat $0). ...

No warning from gcc when function definition in linked source different from function prototype in header

Hi, I had a problem with a part of my code, which after some iterations seemed to read NaN as value of a double of a struct. I think I found the error, but am still wondering why gcc (version 3.2.3 on a embedded Linux with busybox) did not warn me. Here are the important parts of the code: A c file and its header for functions to acqui...

Giving upload folder these permissions safe or not?

I have a classifieds website with a picture script for uploading pics onto the ads. The pics are uploaded to the "images" dir. The php code which does this requires write access to the directory I am guessing... So, what permissions would you set to the php upload file, and the images directory? I am thinking like this: drwxr-xr-x ...

syscall from within GCC inline assembly

is it possible to write a single character using a syscall from within an inline assembly block? if so, how? it should look "something" like this: __asm__ __volatile__ ( " movl $1, %%edx \n\t" " movl $80, %%ecx \n\t" " movl $0, %%ebx \n\t" ...