unix

Is there a standard command-line tool for unix for piping to a socket?

I have some applications, and standard Unix tools sending their output to named-pipes in Solaris, however named pipes can only be read from the local storage (on Solaris), so I can't access them from over the network or place the pipes on an NFS storage for networked access to their output. Which got me wondering if there was an analogo...

How do I prevent Python's os.walk from walking across mount points?

In Unix all disks are exposed as paths in the main filesystem, so os.walk('/') would traverse, for example, /media/cdrom as well as the primary hard disk, and that is undesirable for some applications. How do I get an os.walk that stays on a single device? Related: Is there a way to determine if a subdirectory is in the same filesyst...

Is sed blocking?

I had the impression sed wasn't blocking, because when I do say: iostat | sed sed processes the data as it arrives, but when I do iostat | sed | netcat Then sed blocks netcat. Am I right? ...

How do I cross-compile C code on Windows for a binary to also be run on Unix (Solaris/HPUX/Linux)?

I been looking into Cygwin/Mingw/lcc and I liked to be able to compile perl native C extensions on my windows(preferably under cygwin) and then run them on Solaris and HP unix without any further fuss, is this possible? This all stems from my original perl cross-platform question here. ...

How to compile RDiscount on Solaris?

Hi, I have a few Solaris 10 boxes and I'd like to have RDiscount running there. (They are Joyent accelerators, which have a somewhat customized, BSD-ish, userland, in case it matters.) I'm aware of Maruku, rpeg-markdown and other ruby alternatives to BlueCloth, but initially I'd like to go with RDiscount. Here's what I get when trying...

Videos about Linux and Open Source

I'm looking for some videos about the history of Unix/Linux and Open Source Software. I know (and have) Revolution OS. Are there any others? Edit: I'm a teacher and need resources to show students. Edit: I found Revolution OS on Google Video. ...

Check file size in shell and display file and path above a threshold

I am trying to check for files which are larger than a given threshold. I know that the 'du' comand gives me the output for each file/folder, but how to put that in a single line on shell (using awk with if clause?). ...

With Unix find(1), how do I find files in one tree newer than counterparts in another tree?

Let's say I have two directory structures: /var/www/site1.prod /var/www/site1.test I want to use find(1) to see the files that are newer in /var/www/site1.test than their counterparts in /var/www/site1.prod. Can I do this with find(1), and if so, how? ...

How can you untar more than one file at a time?

I have a bunch of tar files in a directory and I want to extract all the files from them at once. But this doesn't seem to do anything: $ tar xf *.tar What's going on here? How do I untar a bunch of files at once? ...

Why does NFS use UDP by default?

I'm sure there's some ancient legacy reason for it, but what is it? It seems like a service that's geared towards reliable data delivery. ...

Unix O_CREAT flag without mode specified

The definition of the UNIX open() function when used with the O_CREAT flag is that it requires a third argument named mode in order to set the files' privileges. What if that mode is not specified? int file; static const char filename[] = "test.test"; if ((file = open(filename, O_RDWR | O_CREAT | O_TRUNC)) == 1) { perror("Error o...

sed scripting - environment variable substitution

Hi all, I have sed related question: If I run these command from a scrip: #my.sh PWD=bla sed 's/xxx/'$PWD'/' ... $ ./my.sh xxx bla Which is fine. But, if i run: #my.sh sed 's/xxx/'$PWD'/' ... $ ./my.sh $ sed: -e expression #1, char 8: Unknown option to `s' I read in tutorials that to substitute env. variables from shell you need...

Why do programs in Unix-like environments have numbers after their name?

For example, when I run man ioctl the page says IOCTL(2) at the top. What does that mean? Is there an IOCTL(1)? And how does one navigate between these? ...

Will static linking on one unix distribution work but not another?

If I statically link an executable in ubuntu, is there any chance that that executable won't work within another distribution such as mint os? or fedora? I know processor types are affected, but other then that is there anything else I have to be wary of? Sorry if this is a dumb question. Thanks for any help ...

Python - How to check if a file is used by another application?

I want to open a file which is periodically written to by another application. This application cannot be modified. I'd therefore like to only open the file when I know it is not been written to by an other application. Is there a pythonic way to do this? Otherwise, how do I achieve this in Unix and Windows? edit: I'll try and clarify....

Filenames and linenumbers for the matches of cat and grep

My code $ *.php | grep google How can I print the filenames and linenumbers next to each match? ...

mprotect API on tiger!

I'm trying to use mprotect API on MacOSX 10.4 (tiger), I tried every possible way i know , it always returns -1, with errno 13, which means "permission denied" while I'm trying to add the write permission to some executable code. The same code exactly works on MacOS X 10.5 (leopard). the code is pretty simple int ret = mprotect((void*...

How do you execute a command on a remote system insde a BASH script?

As part of an intricate BASH script, I'd like to execute a command on a remote system from within the script itself. Right now, I run the script which tailors files for the remote system and uploads them, then through a ssh login I execute a single command. So for full marks: How do I log into the remote system from the bash script (...

mmaping two consecutive pages

I'm writing a unit test for my UTF8 manipulation library, and I want my test to segfault if a function goes into a buffer overflow. So I came up with the idea to mmap two pages next to each other in memory, the first with PROT_READ | PROT_WRITE, and the second with PROT_NONE. That way, if any overflow occurs, a segfault is guaranteed. ...

Using the open() system call

Hi guys, I'm writing a program that writes output to a file. If this file doesn't exist, I want to create it. Currently, I'm using the following flags when calling open: O_WRONLY | O_CREATE However, when this creates the file, it doesn't give me any permissions to write to it... How can I use open so that it creates a file if it doesn...