unix

Writing my own shell... stuck on pipes?

Hi guys, For the past few days I have been attempting to write my own shell implementation but I seem to have gotten stuck on getting pipes to work properly. I am able to parse a line and fork off the commands between the pipes (ex: ls | sort) individually but can't seem to get them to pipe input from one into the other. I think I jus...

Ignore lines with same next fields as previous

I have a file contents of which looks like this 123,1,ABC,DEF 123,1,ABC 345,4,TZY 456,3,XYZ 333,4,TTT,YYY 333,4,TTT I want to ignore lines with the previous and next contents the same i.e lines containing 123 and 333 Output needs to be 345,4,TZY 456,3,XYZ Any ideas on how to go about this ...

Unix programming... fork() & execv() help... C Programming

I'm writing my own unix terminal and I'm running into a problem executing commands: First I take the user input and store it into a buffer, then I separate the words and store them into my argv[] array. i.e command is "firefox" to launch firefox which is stored in argv[0] How do I launch the command? This is what I'm trying to do, but...

Why do unix background processes sometimes die when I exit my shell?

I wanted to know why i am seeing a different behaviour in the background process in Bash shell Case 1: Logged in to Unix server using Putty(SSH) By default it uses csh shell I changed to bash shell typed sleep 2000 & press enter It gave me the job number. Now i killed my session by clicking the x in the putty window Now open anothe...

executable failing in malloc_y function

we are trying to port our application from HP machine to AIX machine. it was running fine on HP machine but now its failing in malloc_y funtion. but we cant find any clue for this. who is calling this malloc_y function?? please advice. ...

Can you change what a symlink points to after it is created?

Does any operating system provide a mechanism (system call - not command line program) to change the pathname referenced by a symbolic link (symlink) - other than by unlinking the old one and creating a new one? The POSIX standard does not. Solaris 10 does not. MacOS X 10.5 (Leopard) does not. Is there anything that does? (I'm expec...

Linux/UNIX install data files

I understand that when installing a C++ command line program on Linux/UNIX, it is customary instead of leaving it in its original directory, to move it to a directory that is already on the path, so I have a make install entry: mv ayane /usr/local/bin Looking a bit further ahead, I'm going to end up with a directory or two full of con...

execv, wait, Unix programming, How to wait for a child

Hi I'm working on a unix shell and I'm running into two problems. I was wondering if any of you could help me out. My first problem is that the shell is not waiting for the child process to terminate. I can actually go type more commands while the child process is running. My second problems is in the following two lines. I'm not getting...

Need Help Porting Win32 C++ to Unix

I'm looking for help porting this Windows tool to Unix (Mac/OSX); http://www.oxyron.de/html/netdrive01src.zip First off I'd like to know, if anyone could take a moment to have a quick look at the (small) source code, if it's a reasonably straight-forward task. Secondly, any tips on porting the code would be much appreciated. I've tri...

C Programming. Calculate Elapsed Time in Milliseconds (UNIX)

I want to calculate the time in milliseconds taken by the execution of some part of my program. I've been looking online, but there's not much info on this topic. Any of you know how to do this? ...

One-liner to convert two newlines to one?

I have a file where I want to convert "\n" to " " and "\n\n" to "\n". For example: I had a toy . It was good . Becomes: I had a toy . It was good . Does anyone have a Unix one-liner for this operation? ...

How to improve performance of file reading by multiple threads?

I need to read a single file using multiple threads under Linux. There are reading operations only and no need of writing. The file reading don't need read the whole file every time. It need read one or more portions of a file every time. I store the offset of each portion beforehand. The file is too large to put into main memory. So ...

Unix tools in GUI for Windows

I'm a Windows user and would really like to have the power of the Unix command-line for things to speed up programming. (clean up datafiles, search for occurrences of things in files, file/folder operations/ etc.) Now I know that using Cygwin and a few ports, I could use these command-line tools in Windows as well. However, the idea of...

viewing the stack when a crash happens

hi, i am using AIX OS.here i am facing a problem that when ever the process crashes there is no stack written in the log.it just gives an information of signal1/10/4 has occured. but no stack is shown. since the code is an optimized code i am even not able to debud using dbx.gdb is not installed. could you please suggest how to see the ...

Most tricky/useful commands for gdb debugger

Hi All, Can you post your most tricky and useful commands while you run a debugger like gdb or dbx. ...

get a part of a line after grep

I have a huge file on my unix server from which I need to extract certain parts The format of the line is aNumber timestamp commandInformation I use the command grep LATENCY file.log | grep CMDTYPE=NEW to filter out certain lines that I want. I only want the part timestamp and the last 9 characters from the line to be returned, n...

script to get average based on timestamps

I have two fields in my text file which are timestamp number The format of timestamp is hh:mm:ss.mmm some sample records are 18:31:48.345 0.00345 18:31:49.153 0.00123 18.32:23.399 0.33456 I want to print out averages of records which are no more than 30 second apart. what is a good and fast way of doing it ...

Cocoa/ Objective-C Shell Command Line Execution

This is probably a stupid question, but how can I execute a shell command from my Cocoa app? I have the command as a string "command", but can easily manipulate data as needed. There is no need to get a returned output value. ...

A free and relatively simple IDE for Windows XP/Vista/7?

I'm used to using iterations of Visual Studio for my IDE needs, but I've long since wiped the machine I had that on and don't think I can have the program reinstalled on new main machine. Because of this I've mostly been using Geany to write up my code, then FireFTP to send it off to a faraway UNIX machine, then using gcc or g++ to comp...

What is the term for a server looking up domains it hosts?

I am dealing with a server on which curl/wget/links/lynx cannot load any sites which are hosted on the server itself. External sites can be loaded/fetched etc just fine. I want to know the terms I should be using to express this to the sysadmins who insist there is no problem. Thanks! David ...