linux

find the name of user executing the cron

I've got a file index.php. there are 2 users having separate crons running accesing the scripts. is there any function in php/linux to identify which user's cron called that... its a cent-os.. ...

How is it that main function is always loaded at the same address whereas variables have different address most of the time?

Hey guys! I wrote this small program today and I was blown away by the results. Here is the program int main(int argc, char **argv) { int a; printf("\n\tMain is located at: %p and the variable a is located at address: %p",main, return 0; } on my machine the main function is always loaded at address "0x80483d4" and the address of ...

mpg123 on arm-error in writing audio

First off, I don't know if this question is relevant at SO but I'm not getting any responses (yet) from the mailing list.So here goes anyway. I am trying to get mpg123 working on my arm target board.I cross compiled and installed it but when I try to play files, I get the following error : [audio.c:596] error: Error in writing audio (I...

Should I place all the images in the same directory?

I have one simple question. Now I'm working on a e-commerce script and of course users will be able to upload images for each product (up to 10 images for each product). So my question is should I place all the images in the same directory (it will probably be thousands after a time) or create new ones from time to time? Will this slow d...

Get interrupt counters like /proc/interrupts from code?

Hi, I may miss the obvious, but how/is it possible to retrieve interrupt counters for a specific interrupt without manually parsing /proc/interrupts from inside a C/C++ program? Thanks in advance! Best regards, Martin ...

Printing lines from a file where a specific field does not start with something..

Hi, I want to print all the lines where 3rd field (fields separated by : ) DO NOT start with # (to signify that 3rd field is a comment). Please note that there may be space(s) between : and #. Example Input: A:B:#hdfghdfg A:B: #dfdfdfg A:B:C Desired output: A:B:C I tried: awk -F : '$3 ~ /^#/ { print }' run_out5 > run_out6 b...

Installing Watir-Web Driver on Fedora Linux

Hi there, I'm trying to install watir-webdriver by using "gem install watir-webdriver" on Linux. I have installed ruby 1.8.6, activesupport 2.3.8 as well as firewatir. However, when I try to install watir-webdriver, I get the following error: Building native extensions. This could take a while... ERROR: Error installing watir-webdr...

How to test in IE with Linux

Normally I have two computers to work on - my development machine, running Ubuntu, and a testing machine that has Windows. The testing machine is in surgery, and I need to be able to test in IE8. Unfortunately I can't seem to get it to run under wine. I've tried the IE NetRenderer add-on for Firefox, but all it does is take a screenshot ...

How to detect using of wildcard (asterisk *) as parameter for shell script?

In my script, how can I distinguish when the asterisk wildcard character was used instead of strongly typed parameters? This # myscript * from this # myscript p1 p2 p3 ... (where parameters are unknown number) ...

Serial port loopback/duplex test, in Bash or C? (process substitution)

Hi all, I have a serial device set up as loopback (meaning it will simply echo back any character it receives), and I'd like to measure effective throughput speed. For this, I hoped I could use time, as in time bash -c '...' where '...' would be some command I could run. Now, the first problem is that I want to use the device at 2...

Getting all IPv6 addresses on a Linux server

I'd like to find all IPv6 addresses on all interfaces on a Linux server in a C++ program. I'm looking for the equivalent to GetAdaptersAddresses() on Windows. I want to do the same as "ip -6 addr show" does. How "ip" do this ? strace didn't really enlighten me. ...

Linux number of files in directory curiosity

Just out of curiosity, is there any method in Linux to know the number of files in a directory in O(1) (independently of the number of files) without having to list the directory first? I'm searching for an alternative to ls | wc -l. Thanks! ...

Starting default application for a file on Linux

Hey all, I'm working on a Firefox NPAPI plugin + XPCOM component. I've run into a dilemma: Given a file downloaded from the Internet (say a PDF or PNG) how do I start the default helper application to display that file on Linux using C/C++? Currently I'm using the system function call to invoke the gnome-open command and passing it the...

xDebug with specific version of PHP

Is there a specific version of xDebug I should install if I'm running PHP 5.2.10 on my Linux box? ...

Linux Installing Library (ICU) Question

I'm a relative noob to installing libraries. My system currently has an older version of the ICU library (3.8) and I want to go the latest (4.4). Following the steps in the ICU readme.html, everything goes fine (echo $? produces all 0 for every step). And I see the libary was installed to /usr/local/lib. However the current version of t...

What can cause exec to fail? What happens next?

What are the reasons that an exec (execl,execlp, etc.) can fail? If you make a call to exec and it returns, are there any best practices other than just panicking and calling exit? ...

Transcode FLAC on the fly to MP3 for streaming

I have a large collection of FLAC audio files on my server. I would like to be able to listen to them from my computer (preferably over SSH) and from my iPhone. I realize that SubSonic is able to do all of this but I also found a tool called MP3fs which mounts a mp3 transcode of flac files. What solution should I choose and why? ...

How do you Include Short Functions in Awk One-Liners/Single Commands?

I know that usually you don't want one-liners/single commands to get too long but it seems like there's occasionally a longish one-liner that would benefit from replacing repetitive elements with a function. Is it possible to use a short function chop down the length of your command? For example there's no ceiling or round function ...

Self restart program on segfault under Linux

Under Linux what would be the best way for a program to restart itself on a crash by catching the exception in a crashhandler (for example on a segfault)? ...

Can ioctl commands in Linux be completely enumerated?

For the purpose of security-oriented source code review, I'm interested in finding (comprehensively) all ioctl commands that are registered in the Linux kernel. Also, I'd like to classify them as either accessible by administrators (e.g root), and which ones are accessible by unprivileged users. I'm not sure if it would be easier to rea...