unix

Implementing Pipes in a C shell (Unix)

Basically I have created a shell using standard POSIX commands, I want to be able to Implement Piping as well. Right now it handles commands correctly, and can do background processing with &. But I need to be able to pipe using | and >> as well. For example something like this: cat file1 file2 >> file3 cat file1 file2 | more more file1 ...

How to replace catch block in *.java using sed ?

How to replace the following pattern in a java project catch(SQLException e) { \\TO DO } with catch(SQLException e) { S.O.P(); } Please note that the file will have other patterns like catch(IOException e) { // To Do } which should not be changed. I tried sed 's/catch\(SQLException[^\}]*}/catch(SQLException e)...

Standard Error and popen(): how to do it?

I want to open a process from C code, and be able to read its standard output and standard error, while being able to write to its standard input. The closest I get to achieving this is using popen(), but this does not allow you to read the standard error stream. You could add "2>&1" to the command, but this will not make it possible to...

Default Unix test page raplacement

I hast my site on Unix, using CentOS. Is there a way to modify the default CentOS screen? Where is the file stored? ...

Fair comparison of fork() Vs Thread

I was having a discussion about the relative cost of fork() Vs thread() for parallelization of a task. We understand the basic differences between processes Vs Thread Thread: Easy to communicate between threads Fast context switching. Processes: Fault talarance. Communicating with parent not a real problem (open a pipe) Communica...

How to temporarily turn off certain unix cronjobs using a script

I have few cronjobs running everyday Mon-friday.At times during holidays, i turn them off manually so that it doesnt run that day and turn back on the next day. Is there a way to automate this using a script ...

Trying to pass regular expression to grep

I'm trying to exctract error lines from my log file: I used this : more report.txt | grep -E (?i)(error) I'm getting this error msg : bash: syntax error near unexpected token `(' What am I doing wrong? I'm trying to extract all lines containing "Error" ignoring the case sensitivity so it can be error, Error, ERROR etc. ...

Looking the best way to start jboss

I'm trying find out, how to start jboss with cron job at a particular time. What I'm doing at the moment is setup a cron, then inside jboss startinstance script I put sleep 700 seconds untill jboss starts. Is there a better way to actually know when jboss has successfully started and then continue with the flow after, instead of sleep...

Why are malloc() and printf() said as non-reentrant ?

In UNIX systems we know malloc() is a non-reentrant function (system call). Why is that? Similarly, printf() also is said to be non-reentrant; why? I know the definition of re-entrancy, but I wanted to know why it applies to these functions. What prevents them being guaranteed reentrant? ...

Print columns with Awk or Cut?

I'm writing a script that will take a filename as an argument, find a word a specific word at the beginning of each line - the word ATOM, in this case - and print the values from specific columns. $FILE=*.pdb * if test $# -lt 1 then echo "usage: $0 Enter a .PDB filename" exit fi if test -r $FILE then grep ^ATOM $FILE | awk '{ print ...

implement unix pipes in haskell

I'm writing a mini shell and although I've got most of it planned out, one thing I'm not sure how to do is implement piping the output of one program as the input of another. Is there a sample or something that can point me in the right direction? ...

Shell Scripting. Logical ERROR

I have written a shell script with a switch case and takes in options 1-5 and performs operations on the variables accordingly. My code works fine though theres a small change I would like to make in my code. When the code Enters the default case argument,after that it still prompts for "Enter two numbers: " and then prints "Invalid Op...

Which IDE are you using under Unix/Linux for visual debugging?

I usually build the application in windows and test /port the application in UNIX using VI But what is I need to build the application from scratch in unix/linux in shell what option do I have to Visually debug (break point and such .. ) or syntax helpers? ( c/c++) ...

Unix script to compress any format of files

Im a new to Unix shell scripting .I have to write a Unix script A) To find a files in a particular directory which has got csv as well .txt B) Compress those files both csv and txt c)currently under that have not been modified in 1095 days d)Send a mail to the receipent Kindly help me ...

how to use ctrl-D in a shell script

Hi Everyone, I have a bash shell script that requires ctrl-D to break out of the terminal.can anyone tell me how to use it in the shell script example ssh host last --->displays the list of users who were logged on to that host i have different hosts the output is appended to one final and when i'm executing this particular shell s...

AWK/SED remove columns that contain parenthesis

Hi all, I was wondering if it would be possible to remove columns within a data file that contain any parenthesis that can be contained in ANY column. For example ... John Doe (Tech Department) 09/12/2009 555-555-5555 Jane Smith 09/12/2009 555-555-5555 (Suspended) Alfred doe 555-555-5555 (Vacation) 09/09/2011 ... So then I would like...

Output Redirection in C shell

I asked about pipes in a previous question, got that working perfectly. However I had some questions about output redirection like >> in a shell normally does. There doesn't seem to be a whole lot of info on the Internet about it. Here is what I have so far. Is there a better/easier way to do this, it's messy and im not even super sure t...

File Descriptor Sharing between Parent and forked Children

I am a beginner in network programming.. i follow stevens and implementing UDP server with reliability. i have a question. when a child is forked what happens to parent socket fd in child ...? i read that they get inherited that means we have two copies of socket fd in parent and child ?? do we need to close the inherited parent socke...

Cannot append to file when some other process writes to it on *nix systems

I have a very simple piece of code which just writes a small amount of data to a file at some regular interval. Once my program has created the file and appended some data, when I open this file in vim(or any other editor for that matter) and edit it, my process cannot seem to update the file anymore. I do not see any errors being return...

Why is java.lang.UNIXProcess.forkAndExec(Native Method) hanging

Hi, I have a java application running on Solaris. This application regularily launches external processes using Runtime.exec. It seems that after a while, having successfully launched such processes many time over, a launching of a process will hang. A thread dump taken at this point (and several minutes later) reveals that java.lang....