unix

How can I tell if a file is older than 30 minutes from /bin/sh?

How do I write a script to determine if a file is older than 30 minutes in /bin/sh? Unfortunately does not stat exist in the system. It is an old Unix system, http://en.wikipedia.org/wiki/Interactive_Unix Perl is unfortunately not installed on the system and the customer does not want to install it, and nothing else either. ...

Starting up a screen (unix command) + running a command  in 1 command?

Hello. Was wondering how I can start up a command such as: while :; do ./myCommand; done; But instead of doing the usual screen -S nameOfMyScreen Then the command while :; do ./myCommand; done; Then detach the screen ^a ^d (Control "a" the control "d" I would like it to start and detach. Thanks! ...

How to acess ctime, mtime, … of a symbolic link?

On unix symlinks are pointers to another file. Not only the file but also the symlink has a ctime, mtime, …. I know the symlinks time can be accessed, as ls displays it. If I use one of ruby's File#ctime, File#mtime, …, I always get the attribute of the file the symlink is pointing to, not of the symlink. How can I read this values in ru...

Unix permissions, read vs. execute (PHP context)

I have a php script which needs to connect to a database. The credentials for the database are stored in another php script. If I set the permissions for the credentials file to 661 so that Public has execute permission but not read permission, does this allow the main script to access the credentials and connect to the DB while prevent...

Get stack backtrace of a running process

I'm trying to get the stack backtrace of a running process (PID and binary path are known) from another program. The program in question is written in C++ and compiled with g++ with gdb debugging symbols. I'm looking for a C or C++ library that works across Linux, HP-UX and Solaris that produces an output similar to the output of callin...

PHP and CHMOD question

Hi, I want my PHP software to be able to auto update. For this to work, I need PHP to be able to write into files both existing and non-existing (create). Will it always work if I just CHMOD the target files to be 0777 and then write into it? Or does the PHP/Apache/wtvr process need to be the owner of the file? Sometimes when people up...

Trying to get a solid Python install working on my Mac?

I have Mac OSX 10.5.8 with Xcode installed. I want to avoid MacPorts and want to just get a solid Python install foundation so I can then move on to mess with Django and other things. I want to use Buildout with my Python applications. I have installed binary Python 2.6.4 from the official site and installed this. Following other advice...

How to read and write contents from char array to a file?

Hi, this program accepts user input and saved to a char array. Then creates a file and put those texts to the new file. Problem is, it can only copy the part before space. Current Output : "how to read" --> "how" #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> int main(int argv, ...

Oracle scheduled tasks?

I'm drawing a design for a system to do daily business functions for my company. It will consist of a Oracle 10g database with Pl/SQL packages and a Java-based web application. All of this is running on a Solaris 10 server. Aside from handling transactions from the web interface, scheduled tasks need to run on the database to run calc...

How do I interact with a MS Exchange calendar from a Unix command line?

I want to write a bot that will automatically watch a MS exchange account's calendar and accept and log any invitations. The rest of the code will be in Ruby, so I'd prefer that, but I'm happy to use any POSIX tool -- a C program, a Perl script, etc. I've looked around for Unix client information, but all I found were email clients (e.g...

Easy Way to Split a Large Text File?

I've got a large (by number of lines) plain text file that I'd like to split into smaller files, also by number of lines. So if my file has around 2M lines, I'd like to split it up into 10 files that contain 200k lines, or 100 files that contain 20k lines (plus one file with the remainder; being evenly divisible doesn't matter). I coul...

How do I extract lines from a file using their line number on unix?

Using sed or similar how would you extract lines from a file? If I wanted lines 1, 5, 1010, 20503 from a file, how would I get these 4 lines? What if I have a fairly large number of lines I need to extract? If I had a file with 100 lines, each representing a line number that I wanted to extract from another file, how would I do that? ...

Combine 2 lines in large text file using sed

How do I combine two specific adjacent lines in a large text file into one line using sed? For example I want to combine line numbered 2001891 and 2001892 into one line, and write it back to the file at the same line location (meaning line 2001893 and below will get shifted up)? I've googled around for tutorials and manuals on sed but ...

Class-path in manifest not read when running jar in Unix

Hi, I have a client application that needs to run on Unix. It works fine in Windows but i get a NoClassDefFound exception in unix. Here's my manifest file: Manifest-Version: 1.0 Ant-Version: Apache Ant 1.6.5 Created-By: 2.3 (IBM Corporation) Main-Class: com.main.Client Class-Path: lib/commons-lang-2.3.jar lib/commons-io-1.3.2.jar lib/...

Is there any formal way or known way to canonicalize an xml file to generate diffs?

There seems to be many questions WRT tool to generate diffs between xmls, but there wasn't this question yet, so anyone who knows this show me a link or paste any example anyone already solved this problem. Canonicalizing an xml file means, reordering the appearance of attributes reordering the appearance of tags (selectable by comman...

Diff files present in two different directories

I have two directories with the same list of files. I need to compare all the files present in both the directories using the diff command. Is there a simple command line option to do it, or do I have to write a shell script to get the file listing and then iterate through them? Thanks! ...

Redirect subdomain to /folder

I want to redirect the sub-domain webmail to /roundcube for that domain. This have to work for all virtual hosts in apache. Example: webmail.example.com must point to [www.]example.com/roundcube How is this possible? The server where it has to be done is configured with direct admin :S ...

Separate policy from mechanism: What does it mean?

I've often heard the mantra of "separating policy from mechanism", especially in the context of the Unix philosopy. What does this mean and what are some concrete examples of it? When/why is/isn't it a good thing? ...

unix shell script to get date 30 minutes ago in GMT

Hi, I have a shell script that I want to get the date and time 30 minutes ago in GMT. I have this working great for full hours, but partial hours don't seem to work: 1 hour ago TZ=GMT+1 date +%Y-%m-%d" "%H:%M:%S 2010-01-08 17:43:57 2 hours ago TZ=GMT+2 date +%Y-%m-%d" "%H:%M:%S 2010-01-08 16:44:07 1/2 hour ago TZ=GMT+.5 date +%Y-%...

how to truncate long matching lines returned by grep or ack

I want to run ack or grep on html files that often have very long lines. I don't want to see very long lines that wrap repeatedly. But I do want to see just that portion of a long line that surrounds a string that matches the regular expression. How can I get this using any combination of unix tools? ...