pipes

creating tidy shell script from ugly command line pipeline

Hi I wrote a piped shell command that has multiple pipes in it that works great. I now want to put this in the form of a (tidy) shell script. Here is the script: #!/bin/bash for number in `cat xmlEventLog_2010-03-23T* | sed -nr "/<event eventTimestamp/,/<\/event>/ {/event /{s/^.*$/\n/; p};/payloadType / {h; /protocol/ {s/.*protocol=\"(...

How does my Perl program get standard input on Linux?

I am fairly new to Perl programming but I have a fair amount of experience with linux. Lets say I have the following code:. while(1) { my $text = <STDIN>; my $text1 = <STDIN>; my $text2 = <STDIN>; } Now, the main question is: Does STDIN in Perl read directly from /dev/stdin on a linux machine or do I have to ...

How to send commands to telnet and leave session open

I have to connect to a remote server via telnet and want to send file input there. This is a processor emulator (MCF68k), so I can't just scp the file to the server and run from there. I can send input like this: telnet host.name < input.file Which will successfully transmit the data to the server and run the commands stored that I w...

Properly getting output from a pipe in C / C++

I am writing C / C++ code to run a shell command and capture the output: static const int BUFFER_SIZE=512; // (...) FILE* pipe; char buffer[BUFFER_SIZE]; // (...) if (!(pipe = popen(cmd.c_str(), "r"))) { out("\nProblem executing command: " + cmd + "\n"); return 1; } while (!feof(pipe)) { int read = fread(buffer, sizeof(char),...

What is wrong with this use of PIPESTATUS in BASH?

I have a for loop that I pass through ssh to a server that is formatted to look kind of like this... i=0 for cmd in cmd_list; do ${cmd} | sed "s/^/OUTPUT_${i}_: /" & (( i++ )); done; wait The idea is that the for loop will run a list of commands that I give it and pipe each one to sed where sed prepends each line of output with a comm...

Problem get full contents of boygj.com in feed using Yahoo Pipes

I've tried many times to get full contents of boygj.com in feed using Yahoo Pipes In the pipes is: Fetch feed http://boygj.com/rss.xml Cut content from <div class="content"> to <div class="service-links"> ...all those contents assigned to item.description.content But the pipes always showing wrong cutting. What happened and what i...

How to pipe program output in an editor?

I have my program generating some data. It output everything on standard error. Now I'd like to redirect the output to a newly started text editor, into the main unnamed edit window that shows at startup. I tried with vim and gedit without success. myprogram | gedit myprogram | gvim Anyone knows about an X11 text editor that would su...

Problem get full contents of heroturko.org in feed using Yahoo Pipes

I've tried many times to get full contents of heroturko.org in feed using Yahoo Pipes In the pipes is: Fetch feed http://www.heroturko.org/wallpapers/rss.xml From feed, fetch item.link Cut content from <div class="article"> to <div align="center"> ...all those contents lastly assigned to description This is link to the pipe:http://...

Using the same file for stdin and stdout

I'm writing a application that acts like a filter: it reads input from a file (stdin), processes, and write output to another file (stdout). The input file is completely read before the application starts to write the output file. Since I'm using stdin and stdout, I can run is like this: $ ./myprog <file1.txt >file2.txt It works file...

Windows poll or select on Named pipe

Can I use select and poll on the Named pipe handle in windows? It will be great if an example can be given. (I am very new to windows programming) In case one of process goes down and I am polling on other end, will I get any error message on the other process that the process is down? ...

Unix C pipe Question

I'm trying to understand the usage of pipe. A parent process will pipe and if the parent forks, the child process will inherit the pipe. So now we hae a direct link to the child process and they can communicate? I get lost when we start to close pipes and redirect pipes. Does anyone have a good explanation on closing pipes and redirec...

Pipeline metacharacter in variable in bash

In my bash script I need to check if logger binary exists. If so, I pipe the application output to it. Edit-------- | It needs to be piping, the application should work permanently. --------------- I tried to put the pipeline stuff to a variable and use it later. Something like: if [ -e /usr/bin/logger ]; then OUT=| /usr/bin/logger ...

Is reading/writing to a pipe an expensive operation?

As part of my Uni course we've been shown and asked to use pipes to communicate between processes (using pipe() and fork()) for a few small exercises. No problems getting it to work or with the concept, but outside of these requirements I'm wondering how efficient it is to write and read with a pipe of this type? If I've some value that...

How can I make Bash automatically pipe the output of every command to something like tee?

I use some magic in $PROMPT_COMMAND to automatically save every command I run to a database: PROMPT_COMMAND='save_command "$(history 1)"' where save_command is a more complicated function. It would be nice to save also the head/tail of the output of each command, but I can't think of a reasonable way to do this, other than manually p...

trouble pipeline three commands "dmesg|sort|more" c++/c

I have successfully piped the output of one command into the input of another and then show the output of the second command to the screen. I want to do this with three successive commands. (actually eventually I want to do it with N commands passed into the program at run time. This is my attempt at pipelining three commands together....

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 ...

Using exec and pipe in ant

Hello, I'm trying to run the following command using exec in ant: ls -l /foo/bar | wc -l Currently, I have my exec looking like this: <exec executable="ls" outputproperty="noOfFiles"> <arg value="-l" /> <arg value="/foo/bar" /> <arg value="|" /> <arg value="wc" /> <arg value...

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? ...

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? ...

Hadoop Pipes: how to pass large data records to map/reduce tasks

Hello I'm trying to use map/reduce to process large amounts of binary data. The application is characterized by the following: the number of records is potentially large, such that I don't really want to store each record as a separate file in HDFS (I was planning to concatenate them all into a single binary sequence file), and each rec...