linux

ELF file headers

Hey! A quick question about elf file headers, I can't seem to find anything useful on how to add/change fields in the elf header. I'd like to be able to change the magic numbers and to add a build date to the header, and probably a few other things. As I understand it the linker creates the header information, but I don't see anythin...

Setting environment variables in linux using bash

In tcsh, I have the following simple script working: #!/bin/tcsh setenv X_ROOT /some/specified/path setenv XDB ${X_ROOT}/db setenv PATH ${X_ROOT}/bin:${PATH} xrun -d xdb1 -i $1 > $2 My question is, what is the equivalent to the tcsh setenv function in bash? Is there a direct analog? The environment variables are for locating ...

Is there a standard way to do findfirst, findnext with gcc on linux using stl?

I can't seem to find the _findfirst / findfirst, _findnext / findnext API on gcc for Linux, and would actually rather use the Standard Template Library (STL) for that if it is included there. Does anyone know what API there is available for listing files in a directory under Linux for C++ (gcc)? ...

How to realize a diff function?

How would I go about implementing a diff function, such as stackoverflow's question revision history. ...

How to convert (not neccessarily programatically) between Windows' wchar_t and GCC/Linux one?

Suppose I have this Windows wchar_t string: L"\x4f60\x597d" and L"\x00e4\x00a0\x597d" and would like to convert it (not neccessarily programatically; it will be a one-time thing) to GCC/Linux wchar_t format, which is UTF-32 AFAIK. How do I do it? (a general explanation would be nice, but example based on this concrete case would be...

timerfd_create with debian linux testing on amd64

Hi, I am trying to use timerfd_create and timerfd_settime under Debian Linux lenny. The manpage says to include <sys/timerfd.h>. This file cannot be located on my System. According to the Debian Package Search the only packages with a timerfd.h are the linux-headers-* packets. I have installed the packets linux-headers-2.6.26-1-amd64 ...

What are good Linux/Unix books for an advancing user?

Are there any good books for a relatively new but not totally new *nix user to get a bit more in depth knowledge (so no "Linux for dummies")? For the most part, I'm not looking for something to read through from start to finish. Rather, I'd rather have something that I can pick up and read in chunks when I need to know how to do somet...

How do you handle bandwidth billing on shared servers in apache?

What solutions do you have in place for handling bandwidth billing for your vhosts on a shared environment in apache? If you are using log parsing, does your solution scale well when the logs become very very large? Anyone using any sort of module out there for this? ...

Best LAMP setup for PHP development

I'm a very novice Linux user, and am in the market for a new (virtual) machine after my last (physical) server has annoyed me for the last time, and threatens to die at any moment taking years of hard work with it. I need a LAMP server for web-development (thus require LAMP + SVN + (Trac + Python) at a minimum). Having trawled around th...

Invoking windows batch file from Linux

I have an application running only on Windows and a batch file that launches it. I want to invoke this batch file from Linux, meaning something like Linux batch will launch the windows batch with parameters and this in its turn run my application. Can I do that? How? ...

Using ActiveX objects in Javascript in Linux (in Firefox)

Hi, It's not quite a "programming" question, but I hope its related closely enough. Do you know if it is possible to configure the browser in Linux (e.g. Firefox) to use Wine to create ActiveX objects? I would like to handle web pages that use: var xmlDocument = new ActiveXObject( Msxml2.DOMDocument.4.0 ) etc. in Javascript. ...

Recommend a laptop for programming under linux (Ubuntu).

I want to buy a laptop for programming under linux and I have no idea what specific problems can appear (like "no drivers for device", "impossible to hibernate" and so on...) What should I think of when selecting new laptop for linux? I will run Ubuntu, C++, SBCL, ghc. This laptop is not gonna be graphics-oriented. I've already owned ...

truncate output in BASH

How do I truncate output in BASH? For example, if I "du file.name" how do I just get the numeric value and nothing more? later addition: all solutions work perfectly. I chose to accept the most enlightning "cut" answer because I prefer the simplest approach in bash files others are supposed to be able to read. ...

1ms resolution timer under linux recommended way

Hi, I need a timer tick with 1ms resolution under linux. It is used to increment a timer value that in turn is used to see if various Events should be triggered. The POSIX timerfd_create is not an option because of the glibc requirement. I tried timer_create and timer_settimer, but the best I get from them is a 10ms resolution, smaller ...

Color regex matches - without dropping misses

When using grep --color=always I can get pretty color highlighting for regex matches. However, grep only returns lines with at least one match. Instead, I am looking for a way to simply highlight regex matches, while leaving all other input alone, without dropping lines without any matches. I have tried to get color working with sed, ...

Whats the best book or article you have read on optimizing mysql servers (linux)?

I am searching for a good book or article which will help me optimize my mysql servers even more. I am using InnoDB and want to make sure the whole db is loaded into RAM but don't know how. ...

unix shell script find out which directory the script file resides?

Basically I need to run the script with paths related to the shell script file location, how can I change the current directory to the same directory as where the script file resides? ...

do stdout output with specific speed

For a load test of my application (under Linux), I'm looking for a tool that outputs data on stdout at a specific rate (like 100 bytes/s), so that I can pipe the output to netcat which sends it to my application. Some option for dd would be ideal, but I didn't find anything so far. It doesn't really matter what kind of data is printed (N...

Using iptables to change a destination port

Is it possible to change the destination port of a UDP packet using iptables? I'm trying to get an SNMP agent to send out traps on 1620 instead of 162. Unfortunately so far I've only managed to change the source port: iptables -t nat -A POSTROUTING -p udp --dport 162 -j SNAT --to :1620 ...

How to deal with LinkageErrors in Java?

Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux. My application, using the Java Plugin Framework, appears unable to convert a dom4j-created XML document to Batik's implementation of the SVG specification. On the console, I learn that an error occurs: Exception in thread "...