LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-17-2005, 02:44 AM   #1
ricky_ds
Member
 
Registered: Aug 2004
Location: Bern, Switzerland
Distribution: Kubuntu, FC, RHEL
Posts: 48
Blog Entries: 2

Rep: Reputation: 17
How to create a shell script that reads something from stdin?


I'm trying to intercept stdin in a script, before it gets piped to other commands, send this stdin to a file and have the original stdin piped further.


To clarify, see my situation: the script right now reads like this:

Code:
/usr/local/bin/faxmail -n | /usr/local/bin/sendfax -n -D -R -A -P high -f "$2" -d "$1"
faxmail takes a raw e-mail message from stdin, converts it to postscript and pipes it over to sendfax. I want to write the raw e-mail to a file, for debugging reasons.

I've tried it this way:

Code:
mytmp="/tmp/testfax$$"
while read x
do
  echo $x >> $mytmp
done

cat $mytmp | /usr/local/bin/faxmail -n | /usr/local/bin/sendfax -n -D -R -A -P high -f "$2" -d "$1"
The problem is that the headers of the e-mail have idented lines and if I echo them, the indentation gets lost. I really need everything to be exactly as it came from stdin.

Also, I don't want to intercept my file between faxmail and sendfax, because the output of faxmail is already a postscript document.

Anyone can help me here?
 
Old 05-17-2005, 03:41 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
man tee
 
Old 05-17-2005, 05:06 AM   #3
ricky_ds
Member
 
Registered: Aug 2004
Location: Bern, Switzerland
Distribution: Kubuntu, FC, RHEL
Posts: 48

Original Poster
Blog Entries: 2

Rep: Reputation: 17
Smile

thanks man it worked like a charm
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
redirecting stdin in bash script artur Programming 3 12-09-2011 06:07 AM
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Create CD catalogue using Shell Script Helene Programming 2 04-09-2004 09:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration