linux

Text Pattern Processing in paragraph with unix linux utilities

I have a file with the following pattern (please note this is a file generated using sed, awk, grep etc processing). The part of file input is as follows. filename1, BASE=a/b/c CONFIG=$BASE/d propertiesfile1=$CONFIG/e.properties EndOfFilefilename1 filename2, BASE=f/g/h CONFIG=$BASE/i propertiesfile1=$CONFIG/j.properties EndOfFilef...

Switch user and output variable contents

I am writing a bash script and want to switch to another user, cd into a directory specified by MYDIR in the users bash_profile and list the contents. Currently I have: read username su - app${username} -c ls $MYDIR The output is nothing, my first guess is that it is a problem reading $MYDIR from the users profile as doing it manuall...

Linux Kernel: copy_from_user - struct with pointers

Hello, I've implemented some kind of character device and I need help with copy_ from_user function. I've a structure: struct my_struct{ int a; int *b; }; I initialize it in user space and pass pointer to my_struct to my char device using 'write' function. In Kernel's Space character device 'write' function I cast it from a *char...

How can you take ownership of a hid device?

What I would like to take ownership of a hid device that may already have been plugged in, consume it's output, while preventing others(X11 or terminal) from consuming it. If I can help it, I don't want to pretend to be a terminal, but rather to monopolize a particular hid or character device. The idea is that some hid devices may be re...

why normal call to if_freenameindex would double free if_nameindex?

I am learning socket programming under Linux,so I make a sample program to list all the network interface,here is the code /* print the name of interface */ #include <sys/socket.h> #include <net/if.h> #include <stdio.h> int main(void) { struct if_nameindex *pif; pif = if_nameindex(); while (pif->if_index) { printf("name: %s \t in...

How to generate random file name under Linux?

I want to make a small program which use local namespace socket and I will need to use temporary file name as address of the socket. So how to generate random file name under Linux? + I'm using the C programming language under Debian Linux. + Acoording to the GNU C Library Reference,tmpname is not safe.But the safe ones tmpfile and mks...

Performance of the c code

I'm using gcc for my c programmes. How can I check which method is faster (suppose that I write a code to swap two numbers and I rewrote the same code using bit operator), is there any tool in linux to check the time,performance and space? ...

Is there any alternative to gcc to do pratical development under *nix?

I have once heard a saying,we could live without linux,but we definitely could not live without gcc.It seems there is only one c compiler in the Linux world.Is there any alternatives to gcc and does programmers under AIX/HPUX/Solaris use gcc to develop programs? thanks. ...

Mutex in shared memory

Suppose a process is creating a mutex in shared memory and locking it and dumps core. Now in another process how do i ensure that mutex is already locked but not owned by any process? ...

Core dump file name truncated

Given the configuration in /proc/sys/kernel/core_pattern set to /cores/core.%e.%p, core dumps are named according to pattern, however for processes running executables with long names e.g. SampleCrashApplication, the generated core file will contain a truncated executable name: /cores/core.SampleCrashAppl.9933 What is causing this ? The...

DDD Alternative that also Draws Pretty Pictures of Data Structures

Is there anything other than DDD that will draw diagrams of my data structures like DDD does that runs on Linux? ddd is okay and runs, just kind of has an old klunky feeling to it, just wanted to explore alternatives if there are any. The top part with the grid of this image is what I am talking about: ...

how do i run valgrind to a process which has super user bit on?

I am running valgrind as follows:- /usr/local/bin/valgrind "process_name" After excecution its giving me following error ==21731== ==21731== Warning: Can't execute setuid/setgid executable: ==21731== Possible workaround: remove --trace-children=yes, if in effect ==21731== valgrind: "process name": Permission denied My valgrind per...

Having problems creating a new project in Zend Studio 7.0.2 (ubuntu 9.10)

Hi, I've just installed Zend Studio 7.0.2 on my Linux-Ubuntu 9.10 system. There were no problems during the installation but when I try to create a new project, the 'New Project' form hangs when I click the 'Finish' button. I can cancel the form but no project is created. I suspect it may be a permissions problem!? I have Zend Studio...

How do you fix loading plugins in eclipse 3.5.1 on linux?

I have two linux boxes. Both Fedora 11 x64. On one, I downloaded the eclipse-java-galileo-SR1-linux-gtk-x86_64.tar.gz. I unpacked it to /opt/eclipse-3.5.1/ and used the Install New Software... item to install the SVN team provider and the Polarion SVN connectors. Everything works. On the second, I copied the tar.gar for eclipse ther...

Find file launching a process

I think my server has been compromised and it has many perl processes running. However, I don't know what file they are being launched from so I can delete it. How can I find this information? ...

How can I create a process in a portable manner?

Hi, I'm trying to write a program which needs to create some other processes. I'm used to the Windows API but now I need my program to be able to run in a Linux platform too. Is it possible to do it in a portable manner? Do I have to use the preprocessor for that purpose? EDIT: I need to wait for it to finish before continuing to do th...

Using tcpdump, how do I see as plainly as possible an unencrypted SMTP conversation?

I'm trying to debug an application and it isn't a place that's convenient to run WireShark. I've been using "tcpdump -nn -x -X port 25" but the output isn't really in the most convenient format. Thoughts? ...

svn setup permission issues

I'm having trouble setting up my svn. I used apt-get install subversion to install the software. The default svn folder was /home/svn/ I changed the ownership of the folder to an administrator account (not root) and a subversion user group I setup. I set the folder permissions to 0760 recursively through all the subfolders. Yet whenever...

Python library for Linux process management

Hello, Through my web interface I would like to start/stop certain processes and determine whether a started process is still running. My existing website is Python based and running on a Linux server, so do you know of a suitable library that supports this functionality? Thanks ...

Putting a complete filesystem into revision control

I am currently working on a PXE bootable environment that I would like to put into revision control. The filesystem and server will both be Linux (SLES if you must know). I've considered using some kind of hack that stores file ownership/permissions via getfacl -R -P, but this doesn't cover symlinks or devices. And it's kind of ugly. ...