linux

BASH script - How to get bash to check for the location of a file?

Hi I want my bash script to find where php is installed - this will be used on different linux servers, and some of them won't be able to use the which command. Anyway I need help with that second line: #!/bin/bash if (php is located in /usr/bin/php); then PHP = /usr/bin/php else PHP = /usr/local/zend/bin/php fi $PHP script.php ...

chdir() not affecting environment variable PWD

When I use chdir() to change the current working directory, why doesn't the getenv("PWD") give the present working directory? Do I need to setenv("PWD",newDir,1) also? void intChangeDir(char *newDir) { if( chdir(newDir)==0 ) { printf("Directory changed. The present working directory is \"%s\" \"%s\"\n",gete...

Can i install cPanel or plesk control panel

I have got rackspace cloud server and i have installed lamstack and more. Its too hard to use command prompt to my client, so he wants cPanel or plesk control panel. Is it possible to install any one of those? Which one is best and free or open source. Please suggest me. ...

Using ptrace to write a program supervisor in userspace.

I'll looking for advice/resources to write a program that can intercept system calls from a programm to supervise it's filesystem, network, etc access. The aim of this is to write an online judge, so that untrusted code can be run safely on a server. This is on linux, and I would prefer to write C++ or a scripting langauge (ruby, pytho...

Trouble with dup2

After incorporating Ben Voigt's answer into the code, it appears to work Original question: I'm trying to use dup2 to: pass the output of "ls -al" as input to "grep foo", whose output becomes input for "grep bar", which finally outputs to stdout. The final output is (blank), the file "in" is (blank) & the file "out" has the outp...

gentoo geoip installation

Hi experts, I try to install the geoip extension through SSH on my gentoo server. I did: emerge Geo-IP : OK pecl install geoip : OK geoiplookup www.bbc.co.uk : gives me GeoIP Country Edition: GB, United Kingdom GeoIP City Edition, Rev 1: GB, N7, Tadworth, (null), 51.283298, -0.233300, 0, 0 GeoIP City Edition, Rev 0: GB,...

c++ : vector addition operation

Hi, I am trying to add two Vectors below is the code snippet :- #include <iostream> #include <vector> using namespace std; int main() { unsigned int i = 0; vector <float> v1; vector <float> v2; vector <float> v3; cout << "Filling the Numbers\n"; for (i=5;i < 125 ; i = i + 5) { ...

Using dup2 for piping

How do I use dup2 to perform the following command? ls -al | grep alpha | more ...

Dbus on Kernel to user space

Hello! I have a question regardind dbus on the current(2.6.35) kernel. Is dbus a way of communication between kernel and user space? I can figure it out by myself. For exemple if you make use of the usb driver(inserting something like a usb flash pen) and monitoring the activity of the dbus(dbus-monitor) the answer might be yes. But in ...

Reading data files in python 3.1

I am working on a project that is using data files from another program. My first attempt at reading the files was to open one of the files in binary mode, read the first 100 bytes and print the data to the terminal. I am not sure how to decipher the data that was displayed. The output that I got was: b'URES\x04\x00\x03\x00\x00\x00\x...

Seed random from milliseconds in Windows and Linux

Hey, I need to seed the random number generator in boost (which is loaded from an int) for a few processes, for a program that has to compile and work both in Windows and in Linux. I used std:time(0), which worked, but since the processes are jobs which are run simultaneously, some of them would run at the same second, producing the s...

Multithread and SMP Linux

The Linux Kernel is said to be SMP. It is said that processes and kernel threads shall be distributed across processors. Does all Linux distribution like fedora13, ubuntu 10.04 Lucid by default enable SMP Linux? On an SMP Linux, which is better to follow- a) multi-process approach versus b) multi-threading approach Does pthrea...

Shell script that writes a shell script

Two questions: how can I write a shell variable from this script into its child script? Are there any easier ways to do this? If you can't follow what I'm doing, I'm: 1) starting with a list of directories whose names will be stored as values taken by $i 2) cd'ing to every value of $i and ls'ing its contents 3) echoing its contents ...

Custom Linux GUI: Where to begin?

I've had a long standing interest in developing an OS UI tailored to my needs and interests. When I was younger, I went crazy playing with the Stardock skinning tools for Windows. I loved developing my own window styles and layout ideas. Since then I've had an unscratchable itch. I'm not particularly interested in fiddling with the low...

Java memory usage on Linux

I'm running a handfull of Java Application servers that are all running the latest versions of Tomcat 6 and Sun's Java 6 on top of CentOS 5.5 Linux. Each server runs multiple instances of Tomcat. I'm setting the -Xmx450m -XX:MaxPermSize=192m parameters to control how large the heap and permgen will grow. These settings apply to all the ...

How to return only part of a line with egrep

I have a program that returns something like this: status: playing artURL: http://beta.grooveshark.com/static/amazonart/m3510922.jpg estimateDuration: 29400 calculatedDuration: 293000 albumName: This Is It position: 7291.065759637188 artistName: Michael Jackson trackNum: 13 vote: 0 albumID: 3510922 songName: Billie Jean artistID: 39 son...

How can I make a linux module load another module?

I have the task to program one module to store some data and another module to control the first one, been able to load/unload it from the code. I'm and kernel programming ignorant but i've tried hard to find the way to do this. Is there any function to do this? Thank you very much in advance ...

How to intercept keyboard shortcuts in GNOME

I want to write an application which will intercept some keyboards sequences (like those in Emacs – "C-c C-c") and run some function. How can I do this in GNOME? On wich level I should do that (kernel, X11, window manager)? ...

compilation error in webkit-gtk

I am getting following error while compiling webkit-gtk for directfb, any guess how to resolve it? make[1]: Entering directory `/home/sunny/svn/iSense-E/trunk/stable/thirdp/src/webkit-1.2.0/WebKitBuild/Release' /bin/mkdir -p ./.deps/DerivedSources CC WebKitTools/GtkBonker/Programs_GtkBonker-GtkBonker.o CXX WebKitTools/DumpRen...

Why does the following code raise a SegFault. c(Linux)

This a code that would reverse the data of a document and save it in the same document itself. However I am getting a Segmentation Fault.Please Help,I don't know why it gives a SegFault. #include <stdio.h> #include <stdlib.h> #include <termios.h> #include <fcntl.h> #include <string.h> #include <unistd.h> int main (int argc,char* argv[...