linux

How to fetch network card configs remotely from multiple Linux machines?

I need a tool/script to fetch network card configurations from multiple Linux machines, mostly Red Had Enterprise 5. I only know some basic bash, and I need something that can be run remotely pulling server names from a CSV. It also needs to be be run quickly and easily by non-technical types from a Windows machine. I've found WBEM/CMI/S...

Reading Text with Accent - Python

I did some script in python that connects to GMAIL and print a email text... But, often my emails has words with "accent". And there is my problem... For example a text that I got: "PLANO DE S=C3=9ADE" should be printed as "PLANO DE SAÚDE". How can I turn legible my email text? What can I use to convert theses letters with accent? Tha...

C++ FileIO Copy -VS- System("cp file1.x file2.x)

Would it be quicker/efficient to write a file copy routine or should I just execute a System call to cp? (The file system could differ [nfs, local, reiser, etc], however it would always be on a CentOS linux system) ...

How can I get system load/cpu usage from Java?

Normally I call in bash "mpstat 1". Is there an equivalent Java library to aviod calling bash and parsing mpstat output? ...

getpeername() Returns Wrong Data

I am writing my first sockets program on Linux and am trying to print the IP address and port of the peer I have connected to. I use getpeername() along with inet_ntop() and ntohs() to get the data out of the sockaddr_in struct. When I look at the results, I get an IP address that does not go to any server that I know of (ping fails) a...

Is there an equivalent of `tail -f` in Perl?

I'm writing a script that listens for changes to a log file and acts appropriately. At the moment I'm using open my $fh, "tail -f $logfile |"; but ideally I don't want to use system calls. I've tried File::Tail but it has a minimum interval of 1 second (I've tried passing less but it defaults to 1 second, even if I pass 0). I've check...

multithreading: how to process data in a vector, while the vector is being populated?

I have a single-threaded linux app which I would like to make parallel. It reads a data file, creates objects, and places them in a vector. Then it calls a compute-intensive method (.5 second+) on each object. I want to call the method in parallel with object creation. While I've looked at qt and tbb, I am open to other options. I plann...

Use callgrind as a sampling profiler?

I've been searching for a Linux sampling profiler, and callgrind has come the closest to showing useful results. However the overhead is estimated at 20--100x slower than normal. Additionally, I'm only interested in time spent per function (with particular emphasis on blocking calls such as read() and write(), which no other profiler wil...

Whats the difference between the two command lines? (SegFault)

I have written a code that maps to a shared memory location,so that the first program opens a shared memory block and stores some data in it.And the second program reads the shared data. Whats the difference between the two command lines: 1. if(argc<2) { printf("USAGE:%s text-to-share\n",argv[0]); } This code gives me a Segm...

Linux 64 command line parameters in Assembly

This description is valid for Linux 32 bit: When a Linux program begins, all pointers to command-line arguments are stored on the stack. The number of arguments is stored at 0(%ebp), the name of the program is stored at 4(%ebp), and the arguments are stored from 8(%ebp). I need the same information for 64 bit. Edit: I have working code...

Finding source code for login

I set "user1 hard maxlogins 2" i found "logged in as user1 twice" While logging for third time it said "Too many logins" - So i logged out "logout" from previous two logins ...even now it says the same error msg I can verify this using "who" command running as root and check pam.d/login looks fine too. I think ,its bug with login bi...

Apache Alias or ScriptAlias in use with PHP doesn't work

I'm trying to set an Alias in Apache to use for PHP files where all my PHP scripts reside. Usually, we write: Alias /php-bin/ "/var/www/php-bin/" Unfortunately this doesn't work for PHP: <?php require /php-bin/file.php; ?> Apache still understands the Alias (I made some tests), PHP however doesn't find the Alias the way it's suppos...

What's a very efficient way to have a bulk mailer app keep accurate track of its progress?

We have a console application (currently .NET) that sends out mail in bulk to people that have subscribed to a mailing list. We are re-implementing this application because of limitations that it currently has. One of the features it must have, is that it can resume after an unexpected interrupt of its operation. This means that every t...

gcc - writing and executing code in the bss - setting the permission flags

Hi all, I am generating x86-64 code at runtime in a C program on a linux system (centos 5.4 to be exact). I generate my bytecodes into a global array as shown below char program[1024 * 1024] __attribute__((aligned (16))); and then call into it via a function pointer. My issue is, when I compile the program like this gcc -std=gnu99...

How to run a shell command through PHP code?

Hello Experts, I am trying to run a Jar file in the backend of my php code.But I am not getting the desired output to it.There is a jar file which runs in the background and returns the Page Rank of any of the keyword and Domain given to it. I am attaching the code,please suggest me any solution to it,because when I run it on the termin...

How to compile driver to be profiled with Gprof

Simple question.. how to compile driver to be profiled with Gprof? My current Makefile: obj-m += hello-2.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean Works just fine ( I can load the driver etc. ), but if I try to add -pg options to t...

How to emit dbus signal from command line

Hello, Is there a way to emit dbus signal from command line using dbus-send or something else ? Regards, Levon ...

Where to put third party libraries to setup a c++ linux development environment?

Hello all! I'm not new in C++ although I'm new in Linux. I'm using CMake to precompile a cross platform game engine with some third party, but I have a lot of doubts about using libraries. My question is how to work with third party libraries. And where to put this libs. Apt installs libs in their official place (/usr/local, /usr/lib/ .....

Calling Linux command line in MATLAB

I have recently learned, that in MATLAB, the "!" mark runs the code in a command line and follwed by the "&" will pull up the command window, FOR EXAMPLE: !RUN_FILE.bat& It was a great day when I discovered this, or should I say when someone told me this. Anyways I was wondering if there was a way to run this batch file on a linux ma...

Implementing a tree in C++

Hello, I'm trying to implement a generic hierarchical tree for C++ Linux project. I haven't been able to find any standard library tree containers, though. Do any exist? Thanks in advance, Tim ...