unix

Extract e-mail attachments on Unix

Hello, Do you know how to extract attachments from a raw mail message on Unix? I want to do it from shell script (ksh). The mail file is the raw e-mail with headers and encoded attachments.. PS: I can't use perl! Thx. ...

How to custom display prompt in KSH to show hostname and current directory?

I'm using Korn Shell on Solaris and currently my PS1 env var is: PS1="${HOSTNAME}:\${PWD} \$ " And the prompt displays: hostname:/full/path/to/current/directory $ However, I'd like it to display: hostname:directory $ In other words, how can I display just the hostname and the name of the current directory, i.e. tmp or ~ or public_h...

shell script to link specific files up one level

I've got a folder that's got a whole lot of folders inside, which each contain a movie file. Now I want to be able to see all these movies at one time (but I have to preserve the folder structure) so I wanted to symlink them all to the top level folder (flat view in Directory Opus would be the go here, but I'm on a mac). Here's my attemp...

How can I programmatically verify if a CYGWIN app is installed in a SH script ?

Here's the situation : I am writing a SH deployment script that will deploy a website with an RSYNC command in CYGWIN. After the installation, I want to send an e-mail to the development team to say that a deployment has been made with some details. I will use "exim" to send the mail from CYGWIN. The thing is that, exim is only optio...

Information about SCO Unix Com ports

I am trying to talk to a SCO Unix box through the Serial Port where there an existing application. I need to figure out what parameters the application set the serial port too. This is an older non-GUI version of Unix so I need to be able to do this from the command line. I know it involves using /dev/tty* however I am having difficul...

Unix sort treatment of underscore character

Hi, I have two linux machines, on which unix sort seems to behave differently. I believe I've narrowed it down to the treatment of the underscore character. If I run sort tmp, where tmp contains the following two lines: aa_d_hh aa_dh_ey one machine outputs aa_d_hh aa_dh_ey (i.e. '_' precedes 'h') while the other outputs aa_dh_e...

svn post-commit hook doesn't have permissions to create file in working copy directory

I am stuck with that task. I've written svn post-commit hook, that should update working copy on server, if something was changed. But seems to be it doesn't have permissions on that folder, but I've set them to allow everybody to write and read there. So here is the test script: #!/bin/sh REPOS="$1" REV="$2" DIR="/root/root/trunk" ...

How do I configure/make/install against an older version of a library?

I'm trying to install a piece of software (moddims) that depends on "Imagemagick 6.3.9+" - I tried installing the latest version of ImageMagick (6.5.4-5) but got the following error when I tried to "make" moddims: mod_dims_ops.c: In function ‘dims_smart_crop_operation’: mod_dims_ops.c:34: error: too few arguments to function ‘ParseGravi...

How do I replace a token with the result of `pwd` in sed?

I'm trying to do something like this: sed 's/#REPLACE-WITH-PATH/'`pwd`'/' Unfortunately, I that errors out: sed: -e expression #1, char 23: unknown option to `s' Why does this happen? ...

excluding first and last lines from sed /START/,/END/

Consider the input: =sec1= some-line some-other-line foo bar=baz =sec2= c=baz If I wish to process only =sec1= I can for example comment out the section by: sed -e '/=sec1=/,/=[a-z]*=/s:^:#:' < input ... well, almost. This will comment the lines including "=sec1=" and "=sec2=" lines, and the result will be something like: #=sec...

mmaping large files(for persistent large arrays)

Hello! I'm implementing persistent large constant arrays via mmap. Is there any tips and tricks or gotchas one should be aware when using mmap? ...

What are the Python thread + Unix signals semantics?

What are the rules surrounding Python threads and how Unix signals are handled? Is KeyboardInterrupt, which is triggered by SIGINT but handled internally by the Python runtime, handled differently? ...

Hpux telnet using socket

o Sun OS, UTS, AIX etc. But, when the same program is run with HP UX on the other end, we are unable to receive the response from the HP UX box (B.11.31 O/S). sSocket = socket(AF_INET,SOCK_STREAM,0); connect(sSocket,(struct sockaddr *)&sin,sizeof(sin); ierr = read(sSocket,szBuffer,BUF_LEN-1); When the read is called, we get jun...

tree command as a regex, but without the hidden files

Thanks to a nice post at http://murphymac.com/tree-command-for-mac/, I have my long lost linux command tree so I can see the complete directory tree with a single command. I've implemented it via a function in my .bash_profile like this... function tree { find ${1:-.} -print | set -e "s;[^/]*/; ;g" } ...but what I would like is a v...

Why might threads be considered "evil"?

I was reading the SQLite FAQ, and came upon this passage: Threads are evil. Avoid them. I don't quite understand the statement "Thread are evil". If that is true, then what is the alternative? My superficial understanding of threads is: Threads make concurrence happen. Otherwise, the CPU horsepower will be wasted, waiting for (...

What is the best way to manage unix process from java?

I'm looking for some simple tasks like listing all the running process of a user, or kill a particular process by pid etc. Basic unix process management from Java. Is there a library out there that is relatively mature and documented? I could run a external command from the JVM and then parse the standard output/error but that seems like...

Inserting text to a file with Sed within Bash Script

I tried to insert a text to the first line of a file using sed. I do this inside a bash script. But why it hangs at the line of sed execution? #! /bin/bash # Command to execute # ./mybashcode.sh test.nbq nbqfile=$1 nbqbase=$(basename $nbqfile nbq) taglistfiletemp="${nbqbase}taglist_temp" taglistfile="${nbqbase}taglist" ./myccod...

Potential Dangers of ALIASing a Unix Command Starting with "."?

I'd like to use alias to make some commands for myself when searching through directories for code files, but I'm a little nervous because they start with ".". Here's some examples: $ alias .cpps="ls -a *.cpp" $ alias .hs="ls -a *.h" Should I be worried about encountering any difficulties? Has anyone else done this? ...

Unix pipes question

I would like to know, if there is a way to print the pipes associated with a process, like "ipcs -s" for semaphores. ...

What is fadvise/madvise equivalent on windows ?

On UNIX, I can, for example, tell the OS that the mapping will be needed in the future with posix_fadvise(POSIX_FADV_WILLNEED). It will then read-ahead the data if it feels so. How to tell the access intend to Windows ? ...