linux

Futex based locking mechanism

Hello, Somebody can tell me an example of using locking mechanism based on futex? (for muticore x86 CPU, CentOS) Thanks Dima ...

USSD Gateway implementation

I am supposed to develop a USSD gateway for an operator so please help me with the following -can I use asterisk for this purpose? -can the asterisk system take alphanumeric characters as user input. ...

PHP upload permission problem

right guys ive ran into a problem with file permissions with the following upload form. a text file is passed to the upload/ dir by global users. mysite$ ls -l drwxrwxrwx 2 user user 4096 2010-09-24 13:07 upload but as I am not logged in as root, the new file uploaded to the domain saved itself in the upload/ dir with limiting permiss...

need linux equivalent to windows "echo %date% %time% %COMPUTERNAME%"

In Linux, "echo %date% %time% %COMPUTERNAME%" returns %date% %time% %COMPUTERNAME% not Fri 09/24/2010 10:46:25.42 WXP2010043001 as Windows does. I need to be able to do this for the logs I'm setting up. ...

How does my Perl program get standard input on Linux?

I am fairly new to Perl programming but I have a fair amount of experience with linux. Lets say I have the following code:. while(1) { my $text = <STDIN>; my $text1 = <STDIN>; my $text2 = <STDIN>; } Now, the main question is: Does STDIN in Perl read directly from /dev/stdin on a linux machine or do I have to ...

Linux Memory mapped files reserve lots of physical memory

Hi there, I have a problem that was described in multiple threads concerning memory mapping and a growing memory consumption under Linux. When I open a 1GB file under Linux or MacOS X and map it into memory using me.data_begin = mmap(NULL, capacity(me), prot, MAP_SHARED, me.file.handle, 0); and sequentially read the mapped memory, m...

error: ‘LIBNET_ERR_FATAL’ with libnet

I write a demo with libnet, but get an error when call the function: libnet_error(LIBNET_ERR_FATAL, "libnet_open_link_interface: %s\n", errbuf); The error is "error: ‘LIBNET_ERR_FATAL’ undeclared (first use in this function)". my gcc command is: "gcc demo.c libnet-config --defines --cflags --libs", and run on ubuntu. I want to know ...

how can I encrypt an entire column

Hello All, I'm setting up a mail server and I'm mysql for the passwords table. Currently it's secured using the ENCRYPT() function however I have a large CSV I'd like to import where the passwords are all plain text. Is there any way I could import these as plain text and then run a query to run ENCRYPT() on the whole column and update ...

tail file - count number of lines with a given pattern

Hi. I need to guarantee that a specific string is appearing in an active log file, meaning an operation is alive (feeding this count to a Trigger). Considering I'll do this remotely, I can't go with 'tail -f filename' else it would follow the file indefinitely, thus I'm thinking about grabbing a bunch of last written lines and countin...

Large bit arrays in C

Our OS professor mentioned that for assigning a process id to a new process, the kernel incrementally searches for the first zero bit in a array of size equivalent to the maximum number of processes(~32,768 by default), where an allocated process id has 1 stored in it. As far as I know, there is no bit data type in C. Obviously, there's...

How to express "map a linux command to each line in a file"?

Often I need to delete all the files not in a specific svn source tree. To get the list of all their file names, I use: svn st | grep ^? | awk '{print $2}' This command will give me a list of file names, one name per line. Then how can I express the idea of for (each line in ${svn st | grep ^? | awk '{print $2}' ) rm -f line ? ...

What's a good memory-efficient text viewer for Linux?

I need to browse humongous log files from the command line while connected to a web server. I don't want to open the file and have the entire contents read into memory, hogging up the server's memory. I just need to be able to page through and search the log. I usually use "nano". Is this one all right with memory? ...

Running shell_exec('which java') in PHP return nothing

If I run which java from the command line I get the proper input (/usr/java/.../bin/java). However if I run it in a php script: <? echo 'java. ' . shell_exec('which java'); echo 'ls. ' . shell_exec('which ls'); ?> nothing gets printed out for which java but I get the proper results for which ls... ...

Using -exec option with Find command in Bash.

I am trying to use the -exec option with the find command to find specific files in my massive panoramas directory and move them to a specified location. The command I am using below passes an error argument not found for -exec. Can somebody point out my error in parsing the command? Or would I have to create a pipe of some sorts instead...

What is the correct type for this parameter?

This one is for all you ALSA guys. I need a sanity check here. I am using the the alsa-lib api to play sounds and the function that I am using to write the data to the driver is snd_pcm_sframes_t snd_pcm_writei (snd_pcm_t* pcm, const void* buffer, snd_pcm_uframes_t siz...

Linux / Bash, using ps -o to get process by specific name?

I am trying to use the ps -o command to get just specific info about processes matching a certain name. However, I am having some issues on this, when I try to use this even to just get all processes, like so, it just returns a subset of what a normal ps -ef would return (it doesn't return nearly the same number of results so its not ret...

Linux / Silverlight question

I have a PHP script running via crontab on hourly basis under Linux. This script is basically does some tests against database and returns results, smth like: table_name, number_of_rows, number_of_duplicates. Also, I have a Silverlight Dashboard for displaying various data and now I want to include results of the tests. So, question is:...

receive multicast from specific network interface on Linux

Hello, I'm trying to receive a multicast data from specific network interface on CentOS 5.5 sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(1234); addr.sin_addr.s_addr = htonl(INADDR_ANY); bind(sd, (sockaddr*)&addr, sizeof(sockaddr_in)); setsockopt(sd...

Linux command line tools: df and du

What are these abbreviations for? Disk space Free? Disk Usage? ...

Python, os.system for command-line call (linux) not returning what it should?

I need to make some command line calls to linux and get the return from this, however doing it as below is just returning 0 when it should return a time value, like 00:08:19, I am testing the exact same call in regular command line and it returns the time value 00:08:19 so I am confused as to what I am doing wrong as I thought this was h...