Breaking a pipe


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Breaking a pipe
# 1  
Old 06-27-2013
Breaking a pipe

Here's my code -

Code:
for File in "${Files}"; do 
    uuencode "${File}" "$(basename ${File} 2>&-)" 2>&-; 
done | mailx -s "subject" "a@b.c"

Now I want to know if there a way to *not* send an email if the "Files" variables turns out to be blank. Any suggestions?

Also, just to clarify, I was looking for a way to "break" the pipe (advanced stuff) & not the basic variable-check stuff. Thanks!
# 2  
Old 06-27-2013
A pipe "breaks" if the reading end closes first -- next time anything calls write() on the write-end, it will be given the SIGPIPE cleanup signal and die. There's no mechanism for the opposite direction.
# 3  
Old 06-27-2013
Change all references to it from "$Files" to "${Files:?}" as doing it this way abends command if it is null or not set...
# 4  
Old 06-27-2013
How about just:
Code:
if [ -n "$Files" ]; then
  for File in $Files; do
    ...
  done | ...
fi

There should be no double quotes around the $Files in the for loop..
# 5  
Old 06-27-2013
Thanks! I suspected I'm asking too much Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to ignore Pipe in Pipe delimited file?

Hi guys, I need to know how i can ignore Pipe '|' if Pipe is coming as a column in Pipe delimited file for eg: file 1: xx|yy|"xyz|zzz"|zzz|12... using below awk command awk 'BEGIN {FS=OFS="|" } print $3 i would get xyz But i want as : xyz|zzz to consider as whole column... (13 Replies)
Discussion started by: rohit_shinez
13 Replies

2. UNIX for Dummies Questions & Answers

Breaking up at the second occurrence

hi, My input is: 123 1234|123|123|123 123|123|456 123|123|12 12 Expected output is: 123 1234|123 123|123 123|123 456 123|123 12 (1 Reply)
Discussion started by: pandeesh
1 Replies

3. Shell Programming and Scripting

Replace pipe with Broken Pipe

Hi All , Is there any way to replace the pipe ( | ) with the broken pipe (0xA6) in unix (1 Reply)
Discussion started by: saj
1 Replies

4. Shell Programming and Scripting

breaking for loop

Dear Friends, Here I need your guidance once again. I have for loop which check all files in a folder for a particular string. If the string is found in a file it returns value other than 0 else returns 0 value in variable t2. At times the string which we are looking for is in first file... (1 Reply)
Discussion started by: anushree.a
1 Replies

5. Shell Programming and Scripting

Breaking out of loop

I have a main script with while loop having for loop inside. Again in for loop based on if condition few functions will be called. So when a function is called for certain condition it should come out from the main for loop and should continue with while loop. Let me explain with example here: I... (6 Replies)
Discussion started by: vpv0002
6 Replies

6. Shell Programming and Scripting

File breaking

Hey, I have to take one CSV file and break into more files. Let's I have a file prices.csv and the data in the file like 1,12345 1,34567 1,23456 2,67890 2,77720 2,44556 2,55668 10,44996 based on the first column, I want to create files. in this example 1 is repeated three times... (12 Replies)
Discussion started by: bond2222
12 Replies

7. Shell Programming and Scripting

Breaking out of a pipe

I have the following command in a Bash shell script: who | grep -w $1 | some other commands If grep fails, an error message is displayed. How do I test if grep fails and still be able to pipe it's output to the rest of the commands? I have the following solution: a=`who | grep -w $1`... (3 Replies)
Discussion started by: oinkl
3 Replies

8. Shell Programming and Scripting

Breaking line

My input file is like USER_WORK.ABC USER_WORK.DEF I want output file like ABC DEF (4 Replies)
Discussion started by: scorp_rahul23
4 Replies

9. Linux

breaking out of while loop

Hi , I am running this script ( pasting only error code ) to generate some ddl definition for tables . But what I want is to break out of the db2look part when the base_table is not like DIM_$TN or FACT_$TN . After this it should come back to while loop to read the next TN . I read the other... (3 Replies)
Discussion started by: capri_drm
3 Replies

10. HP-UX

Breaking Mirror

Can some one point this UNIX newbie to a web site or directions on the steps needed to break a mirror in HP-UNIX to change a bad hard drive. (4 Replies)
Discussion started by: egress1
4 Replies
Login or Register to Ask a Question