linux

How do I calculate network utilization for both transmit and receive

How do I calculate network utilization for both transmit and receive either using C or a shell script? My system is an embedded linux. My current method is to recorded bytes received (b1), wait 1 second, then recorded again (b2). Then knowing the link speed, I calculate the percentage of the receive bandwidth used. receive utilizatio...

linux: programmatically get parent pid of another process?

I tried google, but found getppid() which gets the parent pid of the current process. I need something like getppid(some_other_pid), is there such a thing? Basically takes the pid of some process and returns the parent process' pid. ...

PHP readdir( ) returns " . " and " .. " entries

I'm coding a simple web report system for my company. I wrote a script for index.php that gets a list of files in the "reports" directory and creates a link to that report automatically. It works fine, but my problem here is that readdir( ) keeps returning the . and .. directory pointers in addition to the directory's contents. Is there ...

I wanna use Java applications in an embedded hardware

Hello everybody! I have to dessign a new harware with a uP (not determined yet) to run JavaME applications. I've searched information about how do it, but for the moment it has been useless. Anyone could explain how I can do it? From what I found in my search: - Using a uP (ARM for example) with an OS (ie: Linux) (using JIT for better...

Cannot read binary video files in GNU/Linux

Hi all. I'm stuck with an apparently harmless piece of code. I'm trying to read a whole flv video file into a uint8_t array, but by no reason only the 10 first bytes are read. contents = malloc(size + 1); if (read(fd, contents, size) < 0) { free(contents); log_message(WARNING, __func__, EMSG_READFILE); return (NULL); } I'...

Linux shell to restrict sftp users to their home directories?

Hiya, I need to give SFTP access to a directory within my webroot on my server. I've set up ben_files as a user and have set his home directory to /var/www/vhosts/mydomain.com/files That's all fine if he connects with plain old FTP - he's restricted just to that directory, but to enable SFTP i had to add him to bin/bash shell, which...

How to write directly to linux framebuffer?

How to write directly to linux framebuffer? ...

Redirect cout to a file vs writing to a file directly in linux

Hello, For C++/linux programs, how does writing to cout (when cout has been redirected to a file during program launch) compare against writing to the target file directly? (via say fstream) Does the system do the appropriate magic at the start of the program to make these two cases exactly equivalent or is the later gonig to be better...

Problem with regular expression using grep

I've got some textfiles that hold names, phone numbers and region codes. One combination per line. The syntax is always "Name Region_code number" With any number of spaces between the 3 variables. What I want to do is search for specific region codes, like 23 or 493, forexample. The problem is that these numbers might appear in the lon...

Recommended method for testing regular expressions?

I'm new to regular expressions, I've been able to write a few through trial and error so tried a few programs to help me write the expression but the programs were harder to understand than the regular expressions themselves. Any recommended programs? I do most of my programming under Linux. ...

Best Visual-Studio Like tool for Linux Development

I need to write a few programs for a project I'm currently working on and I'm very much used to Visual Studio 2008 and I do not mind programming in Python but I need to have a comfortable GUI programming ontop of the language itself, and it has to be well integrated and fast. I know that's a lot to ask for but is there any such thing out...

Illegal Argument Execv() Unix C++

So I basically have a vector args with 1 argument per array that I'm trying to pass to an execv() call in unix. Execv accepts two parameters like so: int execv(const char *path, char *const argv[]); What's the best way to convert my vector of strings to an array of pointers ? Right now I'm doing the following but when I run it with s...

Can't read variable that was stored from within a while loop, when out of the while loop.

I can't for the life of me see why I can not read the postPrioity outside the while loop. I tried "export postPrioity="500"" still didn't work. Any ideas? -- or in plan text -- #!/bin/bash cat "/files.txt" | while read namesInFile; do postPrioity="500" #This one shows the "$postPrioity" varible, as '500' echo "weeeeeeeeee --...

linux: copy and create destination dir if it does not exist

Linux: I want a command (or probably an option to cp) that creates the destination directory if it does not exist. Example: cp -? file /path/to/copy/file/to/is/very/deep/there ...

What is the output of this program?

Hi, when i tried to run compile and execute this statement in a simple c file: main(){ printf("%d");} on HP it's is giving me 64 and on AIX its giving me 804359524. Could anyone tell me what is this behavior. ...

Is it possible to peridocally save state of the program through a core dump?

I just want to dump core without stopping the program. This would be essentialy serializing a whole state of the program. A very convenient thing for debugging later. Is it possible under linux? ...

Finding out if a message over tcp was delivered

When i send()/write() a message over a tcp stream, how can i find out if those bytes were successfully delivered? The receiver acknowledges receiving the bytes via tcp, so the senders tcp stack should know. But when I send() some bytes, send() immediately returns, even if the packet could not (yet) be delivered, i tested that on linux ...

Automated download script

I'd like to run a script that reads a list of URL's from a file and downloads each URL one at a time. The script reads one line from my url list and invokes the command aria2c -D & completes 1st URL then goes to 2nd URL and so on till the end of the list. Help Thanks in advance ...

Launch XDebug in Netbeans on an external request

I'm using Netbeans 6.7 and XDebug to debug a PHP site on my machine, launching the request from within Netbeans (Project->Debug). This works fine, and is very useful. My question is: Is it possible to attach the debugger to any request that comes in, rather just those I launch from within Netbeans? ie, instead of clicking "Debug", pu...

In Linux, polling in a conscientious way

When you've got a tight loop polling the status of something, I'm not quite sure how to do the polling without getting in the way of other processes wanting to use the CPU. For instance, doing this: while (state == BUSY) state = check_state(); seems like a waste of resources. I would think the best way to do this would be: while (sta...