Computing.Net > Forums > Unix > Piping script

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Piping script

Reply to Message Icon

Name: Justin
Date: September 30, 2002 at 00:05:34 Pacific
OS: UNIX
CPU/Ram: N/A
Comment:

I have a program which outputs a result. I am able to specify what it pipes it to, and would like to add an extra line to the end of the result before printing it. The program lets me specify how i would like the result to be received in two ways:
[result] | (piped in)
[result] > (added in)
I can only add commands after it has done this.
At the moment it pipes straight to a print command.
I hope this is clear enough, thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: Jerry Lemieux
Date: September 30, 2002 at 11:21:18 Pacific
Reply:

Try using a named pipe. Shove all your data into the pipe and at the end of the script, you can cat the pipe and send it out through your print pipes.

Here is a simple example of using a named pipe:

PIPE=/tmp/tempPipe
mkfifo -m 660 $PIPE || (echo "cannot create named pipe"; exit 1)
print "\n" > $PIPE &
print "Hi mom" >> $PIPE &
print "Sleeping 5"
cat $PIPE

Do all your writes to the named pipe in background. Otherwise, the script will sit and wait for a reader process for the pipe.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Piping script

Waiting problem - KSH script www.computing.net/answers/unix/waiting-problem-ksh-script/7835.html

Two scripts pipe to a log file www.computing.net/answers/unix/two-scripts-pipe-to-a-log-file/3599.html

ftp sql results in shell script www.computing.net/answers/unix/ftp-sql-results-in-shell-script/6338.html