unix

forking multiple processes and making the parent wait for all of them (in C)

I'm creating various processes (3 to be precise) and making them do different things. So far so good. I'm trying to wait in the parent until all children are completed. I've played around with many options (such as the one listed below) but either the parent waits but I have to press enter to return to the shell (meaning that some child...

System call in unix: directories and files

hi I'm trying to understand system calls: directories and files on unix, .. I found this website where they explain some calls with their own examples, but do not understand these code snippets .. void state (char *file) { struct stat buf; struct passwd *pw; struct group *gr; int i; if (stat(file, &buf)...

How to use loops statements in unix shell scripting

How to use loop statements in unix shell scripting for eg while ,for do while. I'm using putty server. ...

Tools for implementing a watchdog timer in python

I'm writing some code for testing multithreaded programs (student homework--likely buggy), and want to be able to detect when they deadlock. When running properly, the programs regularly produce output to stdout, so that makes it fairly straightforward: if no output for X seconds, kill it and report deadlock. Here's the function protot...

search and replace a string

is there a way to search and replace a string using single unix command grep recusrsively in multiple directories? i know it can be done by using the combination of find with other utilities like sed perl etc.but is there a way where we can use only grep for doing this on unix command line? ...

How to load system-wide daemons on MacOS

I'm trying to load my daemon-app with this command launchctl load /Library/LaunchDaemons/myPlistFileName It works fine, but only while my user is logged in on system. How can i load my deamon-app, which will stay loaded without any user logged into the system (like the windows-services)?? The command sudo launchctl load /Library/Launch...

What does this mean in SVN?

svn up svn: Error writing to '.' svn: Can't write to file '.svn/tmp/entries': No space left on device If my box is out of hard drive space, that is impossible, becauase it has 620GB of HD. ...

Rename files based on sorted creation date?

Hi, I have a directory filled with files with random names. I'd like to be able to rename them 'file 1' 'file 2' etc based on chronological order, ie file creation date. I could be writing a short Python script but then I wouldn't learn anything. I was wondering if there's a clever 1 line command that can solve this. If anyone could poi...

Unix stat()/lstat() for Java

Suppose I want to get several of a file's properties (owner, size, permissions, times) as returned by the lstat() system call. One way to do this in Java is to create a java.io.File object and do calls like length(), lastModified(), etc. on it. I have two problems so far: Each one of these calls triggers a stat() call, and for my pur...

Regarding the bss segment and data segment in Unix

I read in my unix text book that bss is used to store the uninitialized variables(global declarations). This would mean that the static variables are stored separately and not in the bss. The only other place is the data segment. Here is my question: Is bss segment a part of the data segment or are they two entirely different set of me...

How to make SVN ignore a folder?

I want to make SVN ignore everything that is in my wordpress directory. It bring me nothing but headaches because of auto updates to plugins etc. When I... svn propedit svn:ignore ./blog It tells me... svn: None of the environment variables SVN_EDITOR, VISUAL or EDITOR is set, and no 'editor-cmd' run-time configuration option was f...

File r/w locking and unlink

Hello, I have following problem. I want to create a file system based session storage where each session data is stored in simple file named with session ids. I want following API: write(sid,data,timeout), read(sid,data,timeout), remove(sid) where sid==file name, Also I want to have some kind of GC that may remove all timed-out session...

Htaccess rule to redirect domain to index.html

How do I write a rewrite-rule that redirects visitors to the domain www.mydomain.com/ to www.mydomain.com/index.html? ...

Unix System Call in Objective-C

Hi all, Is it possible to make system call in Objective-C? I have the following code: if (!system("ls -l")) { NSLog(@"Successfully executed"); } else { NSLog(@"Error while executing the command"); } How to get the output? Thanks ...

How to replace the last one or two characters of a file with unix tools

I have a hanging comma at the end of a file that I would like to replace with a close square bracket. There may or may not be a newline character at the end of the file as well. How can I replace the one or two characters with the square bracket using common unix tools? ...

What's the difference between using > and >> in shell?

I've seen somewhere that we can use >> in shell. What's the difference between using > and >> in shell? ...

Sun Studio C++ "is not terminated with a newline" warning - how to suppress?

I have ported a fair bit of code from Win to Solaris, one of the issues I have - I am getting a heaps of warnings: Warning: Last line in file is not terminated with a newline. I like warnings - but because of the sheer amount of those I am afraid I could miss more important one. Which compiler (cc) option should I specify to silence...

How to create a zip archive using Ruby on Rails?

I have a bunch of files in a directory. I want to zip some of them together into a zip archive. I can see there are various solutions for doing so. I could use a gem such as rubyzip or run exec and just use a command line tool. This is going to impact an important part of the system I'm working on so I'd love to have some feedback and...

Walking a Linux/Unix filesystem with Java?

I need to create a Java util that will recurse its way through a Unix (and/or Linux) filesystem and build an object model of the directory structure, retrieve file info - size, created date, last accessed date etc - plus I need to retrieve info on the physical storage device the files are sitting on. Ideally, this util will be portable. ...

Passing variable from shell script to sql statement

I was trying to make cat1.txt as a variable ($2) so that it will be inserted in sql select statement. Is there a way to do this? my cat1.txt 1111 2334 2234 3333 4444 .... .... etc. my SQL Statement set echo off linesize 280 pagesize 0 newpage 0 feedback 1 verify off head off trimspool on alter session set sort_area_size=10485760...