linux

Use of clock_getres - newbie Linux C

I'm trying to determine the granularity of the timers on my Linux box. According to the man pages for clock_getres, I should be able to use this snippet: #include <time.h> #include <stdio.h> int main( int argc, char** argv ) { clockid_t types[] = { CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_PROCESS_CPUTIME_ID, CLOCK_THREAD_CPUTIME_ID, (...

When calling a Python script from a PHP script, temporary file that is created on a console run, is not created via the PHP invocation.

Scenario: I have a php page in which I call a python script. Python script when run on the command line (Linux) shows output on the command line, as well as writes the output to a file. Python script when run through php, doesn't do either. Elaboration: I use a simple system command in PHP to run the python script as: /var/www/htm...

Problem replacing Linux system calls using LD_PRELOAD

I am trying to write a program that allows a binary to be run, substituting a certain file when requested with another. It is a library with simple replacements for the system call functions, that is used with LD_PRELOAD. The problem is that it catches opens for reading (the substitute file is read instead), but writes always go back to ...

Why do I get connection refused after 1024 connections?

I am testing on a local Linux server with both the server and client in the same server. After about 1024 connections, in my code, where I connect, I get connection refused. At first I thought it was the fd_set_max limit of 1024 for select and changed the server to do poll instead of select and I still don't get past this number. My ulim...

How would you build a database filesystem (DBFS)?

A database file system is a file system that is a database instead of a hierarchy. Not too complex an idea initially but I thought I'd ask if anyone has thought about how they might do something like this? What are the issues that a simple plan is likely to miss? My first guess at an implementation would be something like a filesystem...

How does iwlist() command scans the wireless networks??

I want to know how iwlist command scans the wireless networks available, in linux. I read its source code and there was an ioctl call using SIOCSIWSCAN to trigger the scan and SIOCGIWSCAN to get the scan results. But how the beacon frames are captured and analyzed by these system calls? ...

Add up a column of numbers at the Unix shell

Given a list of files in files.txt, I can get a list of their sizes like this: cat files.txt | xargs ls -l | cut -c 23-30 which produces something like this: 151552 319488 1536000 225280 How can I get the total of all those numbers? ...

about fork and execve system call

It is said that fork system call creates a clone of the calling process,and then(usually) the child process issues execve system call to change its image and running a new process.Why this two-step? Btw,what does execve stands for? ...

Determining working directory of another program.

Is there any way of determining the current working directory of an already running program in Linux? What I'm trying to achieve is I want to be able to work in a terminal and then have a keyboard shortcut set up which will run a tool which I am writing which displays a little popup window containing some information and a few buttons t...

FIFO (named pipe) messaging obstacles

I plan to use Unix named pipes (mkfifo) for simple multi-process messaging. A message would be just a single line of text. Would you discourage me from that? What obstacles should I expect? I have noticed these limitations: A sender cannot continue until the message is received. A receiver is blocked until there are some data. Nonblo...

SVN checkout the contents of a folder, not the folder itself

Hey, I'm fairly new to linux and svn. I'm trying to checkout the trunk folder of a project into my public_html directory using this command (while in public_html): svn checkout file:///home/landonwinters/svn/waterproject/trunk The waterproject directory contains the files from untarring a base install of drupal. It checks out fine, ex...

How to get the owner and group of a folder with Python on a Linux machine?

Title says it all pretty much. Is there any way how I can find out about the owner and group of a folder with Python? Thank you so much, you guys are amazing! ...

how do I edit a file on command line ?

Hi, I am trying to create a php file that adds a user and create public_html directory in linux using exec() function(php). I can add following code to the php file exec("useradd -d /home/username -m username"); exec("mkdir /home/username/public_html"); now..I have to add public_html to smb.conf to work public_html on windows. is it...

Redefine signal handling flaws

This is about the design decision and understand the procs and cons for adopting another service. So we have two services with two unrelated servers, one listening on port 10000 and another is a xinetd server responding 3 different requests via 3 different ports (its client uses nc server port1|port2|port3 to retrieve data). One day be...

Can spawned Postgresql process be controlled by the spawner PHP script?

I have a PHP CLI script, that processes a csv file, inserting it's content to a table in Postgresql database. This is on an Ubuntu server. I use schedtool to control the affinity of the whole script. Schedtool is used to launch the script itself with the -e option. Unfortunately with htop I see that the database thread is spawned as a co...

Run PHP script when a new file is added via FTP

Hi, I have the following situation Multiple cameras send images at random intervals via FTP to a predetermined folders. EG: recordings/camera1/images/ - for first camera recordings/camera2/images/ - for second camera etc Each of them save images in .jpg format and then close FTP connection. What I need to get done is to call a PHP scri...

Recursive Bulk Edit in Linux

I am trying to change certain lines in multiple files (scattered in subfolders) without having to edit each file one by one. I was given by Chas. the following perl -pi.bak -e 's{[^/]Css/Template.css}{/Css/Template.css}' * and it worked like a charm but was wondering if this command or similar can be done recursively in one shot ...

how do i open a windows in a different X11 session?

linux only: i want to open two windows for my application, one on the main screen of the computer, and one on a virtual X11 sessions to be accessed by remote desktop only. Can some X11 expert tell me how this is done? ...

diacritics problem in project made with Zend Framework

Hi, found a interesting problem during testing our web application. I have application on localhost (Windows) and online testing server (Linux). Both are connected to same DB (on Linux server). When I tried to edit one text field through form in application located on Linux server it crop diacritics from result and save it to DB witho...

Warcraft III + wine + automatic battle.net logon

I need a little bash script which will send keyboard strokes to current running application under linux. This application runs under wine in Xorg. I'm trying to create script to automatically log me into battle.net account in Warcraft 3 game. ...