unix

How to tell if a file handle is a socket?

I need to log socket usage, and I wrote a LD_PRELOAD library. The problem is when I override read() and write() than ordinary file operations are get logged too (of course). So how can I tell ordinary file descriptors and socket descriptors apart? ...

Getting local variables of function

Hi, I'm trying to get a local variable from a decorator. An example: def needs_privilege(privilege, project=None): """Check whether the logged-in user is authorised based on the given privilege @type privilege: Privilege object, id, or str @param privilege: The requested privilege""" def validate(func, self, *args...

Sending emails with postfix via port 587 on gmail

Since my ISP blocks port 25 I'd like to be able to configure postfix to send smtp email over port 587. Every time I try to send an email I see this in the mail.log Oct 17 10:37:49 new-host-2 postfix/smtp[1552]: connect to aspmx.l.google.com[74.125.113.27]:25: Operation timed out I'm assuming this is due to the fact that this doesn't w...

graph in c , recomend book

Is any method or software to plot or display graph on unix dump terminal even the dump terminal is one color only(green)? For my knowledge, we can use text based character to draw graph but not graphic mode. platform is unix ansi c compiler CAN anyone recomend web page or a book ? ...

Are unix process ID's base 10?

After reading a series of man pages and searching through google, I decided to post this question to the bright folks of stack overflow. I'm working on a basic Unix Shell and one of the requirements is that I have to implement a command to echo out the shell's pid in base 10 ASCII... Before I read this requirement, I had assumed that pr...

Terminal - Delete All Folders Not Conatining .mp3 Files

Hi, I'm using Banshee on Linux and I have it auto-organize my music collection in folder hierarchies. When I add a new album to my Music folder, Banshee automatically moves (and renames) the mp3s and puts them into the correct Artist folder. If there is no other file in the folder, then the folder is also deleted, but if other files are ...

Compiling Unix Version 6 in Snow Leopard

Hi i downloaded souce for unix version 6, i want to study it and test it. I am running Snow Leopard on a macbook pro. 1)Is there a way to compile it in mac. If i comile using make or gmake i am getting the following error. *** Error: Couldn't find an i386-*-elf version of GCC/binutils. *** Is the directory with i386-jos-elf-gcc in your ...

Scope of POSIX Threads

I have been learning thread programming in Java, where there are are sophisticated APIs for thread management. I recently came across this. I am curious to know if these are used now. Is the POSIX thread obsolete or is it the standard used now for threading in C++. I am not familiar with Threading in any other language apart from Java. ...

replace a string in huge file by incrementing with it number of appearance in file?

I have a file of 500MB and it has strings : string_1 ..... string_500, I need generate the copy of this file which has : string_501.......string_1000 I need to do this up to string_500000, what's the best way to solve this? ...

Easy way to send a signal to direct children only?

Is there an easy way to signal only direct children of a process? That is, if A spawns B1 and B2, and the B's spawn C's, can A easily signal just the B's? It seems like it should be relatively simple, but I can't find anything, and I'd rather not do anything complicated if I don't have to. ...

64 bit issue causing core

I have recently migrated the code fom 32 bit to 64 bit and have a query. I am geting core in my code after 64 migration. int main (int ac, char *av[]) { char myTable[51]; memset(myTable, 0x00, sizeof(myTable)); myFunc(ac, av, myTable); } myFunc(int argc, char *argv[], char* myTable) { Config config; /*** confi...

Bash: redirecting output from a process that's already running?

Is there a way, in Bash, to capture/redirect the output (and stderr?) of a process once it's already running? ...

AWK/BASH: How to remove duplicate rows from file with known field range?

Hi all, I was wondering if there was a way to use bash/awk to remove duplicate rows based on a known field range. For example: Easy Going USA:22 May 1926 Easy Going Gordon USA:6 August 1925 Easy Life USA:20 May 1944 Easy Listening USA:14 January 2002 Easy Listening ...

Implicit Declaration of Function in C UNIX

In the following code, I get a warning that there is an implicit declaration of function getpgid. I know its only a warning, but its for a class and the professor wants us to treat warnings as errors. So, help please. I have included the appropriate header file as well so I have no idea whats wrong: #include <unistd.h> pid_t pid, pgi...

Failing if diff is found (c-shell)

Please resist the urge to tell me not to use c-shell. I'm writing a c-shell script and I need to run a diff between two files (generated in the script). How do I run diff and return its status (if it fails, return 1, else 0)? ...

How to select a given column from a line of text?

Suppose I have this sentence: My name is bob. And I want to copy the word "is" from that sentence into a variable. How would I access that word, without knowing in advance the word I am looking for? If I know a specific word or string is in the third column of text in a five column text line, how can I take the word in the third colu...

how to include HTML code in Mailx mail body

How can i send the email using mailx command including the HTML code? for example: mailx -s "Report" << EOF Report Generated <table width="600"> <tr><td width="30%">&nbsp;&nbsp;</td><td width="35%" style="font-size:7pt;">Definition</td></tr></table>EOF however the mail did send, but which is not as html code.. Anybody know how to sen...

question about grep pattern

I'm using grep to match string in a file, here is example file : example one, example two null, example three, example four null, grep -i null myfile.txt returns example two null, example four null, How can I return matched line + line number like this : example two null, - Line number : 2 example four null, - Line number : 4...

ClearCase - find all the files that are viewed on a certain branch

In ClearCase, I would like to see a list of all the files that I am viewing on a certain branch (if I have branch Br I would like a list of all the files that I am viewing a version of them in that branch). Is that possible? ...

Value of uninitialized semaphore

With reference to the semaphore implementation of semaphore.h in Linux, does an uninitialized semaphore sem_t default to 0? I just discovered that I had forgotten to initialize my semaphores to 0. Even so, the program worked fine without sem_init. (To all the purists, I completely agree that doing so is a bad practice.) ...