Sponsored Content
Full Discussion: Question about tee command
Top Forums Shell Programming and Scripting Question about tee command Post 302965761 by Aia on Tuesday 2nd of February 2016 06:59:01 PM
Old 02-02-2016
Quote:
Originally Posted by calredd
Sorry, I wasn't clear. My issue is more to do with using the "tee" command which is causing the error checking (in the next if statement) to always pass regardless of the actual command whether it runs successfully or fails.
I understood your dilemma. That's why I gave that snippet. It is not only tee but for any chained commands: $? will report about the last command executed.

Is the following not your intention?
Code:
if [[ -s incoming.dat ]]; then
   echo "data from incoming.dat file as follows:"
   cat incoming.dat | tee -a execution.log
   echo "Execution Log" | mail -s "Log File" -a execution.log info@abc.com
else
   echo "Issue with incoming.dat: file not present or empty"
   exit 1
fi

This User Gave Thanks to Aia For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Tee with pipe command.

cat work.txt M|324324|32424|3431 M|324324|32424|3431 N|324324|32426|3432 N|324324|32424|3434 M|324324|32424|3435 cat work.txt | tee $( grep '^M' > m.txt ) | $( grep '^N' > n.txt ) cehpny00:/home01/sr38632 $ cat m.txt M|324324|32424|3431 M|324324|32424|3431 M|324324|32424|3435 ... (2 Replies)
Discussion started by: rsampathy
2 Replies

2. Shell Programming and Scripting

Is there a way to tee stderr from a command that's redirecting error to a file?

I'm not a complete novice at unix but I'm not all that advanced either. I'm hoping that someone with a little more knowledge than myself has the answer I'm looking for. I'm writing a wrapper script that will be passed user commands from the cron... Ex: ./mywrapper.sh "/usr/bin/ps -ef |... (1 Reply)
Discussion started by: sumgi
1 Replies

3. HP-UX

HP Unix Tee command.

work.txt M|324324|32424|3431 N|324324|32426|3432 N|324324|32424|3434 M|324324|32424|3435 AIX command: cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt ) which does not work on HP? Please adivse us. Error: cat work.txt | tee >( grep '^M' > m.txt ) >( grep '^N' > n.txt )... (7 Replies)
Discussion started by: rsampathy
7 Replies

4. UNIX for Dummies Questions & Answers

tee command within variable

Hello If anybody knows something about the following please help me. I am using HP unix. In a script called test.txt i have the following command echo ok | tee test1.txt It works fine.It prints ok on the screen and creates the file test1.txt and puts in the file the "ok". In the same... (2 Replies)
Discussion started by: kostasch
2 Replies

5. Shell Programming and Scripting

tee + more command

script1: #!/bin/ksh more test.txt script2: calling the script1 #!/bin/ksh /tmp/script1.sh 2>&1 | tee tee.log where test.txt contains ~1200 lines. When I execute the script2 the more command does not print pagewise it goes to the end of the line, when I remove the tee command it... (4 Replies)
Discussion started by: prasad111
4 Replies

6. UNIX for Advanced & Expert Users

Equivalents of tee command to find exit status of command

Hi, Want to log the output of command & check the exit status to find whether it succeeded or failed. > ls abc ls: abc: No such file or directory > echo $? 1 > ls abc 2>&1 | tee log ls: abc: No such file or directory > echo $? 0 Tee commands changes my exit status to be always... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

7. Shell Programming and Scripting

Help with tee command

In the current directory , I have seven files . But when I use the following command , it lists eight files ( 7 files + file_list.xtx) ls -1 | tee file_list.xtx | while read line; do echo $line ; done Does the tee command create the file_list.xtx file first and then executes the ls -1... (1 Reply)
Discussion started by: kumarjt
1 Replies

8. UNIX for Dummies Questions & Answers

Problems with tee command.

for i in /tmp/*filex*; do echo $i |sed 's/\/tmp/infofiles\/infosize\/db\/files\///g';done 2>&1 |tee>output | The script works fine, but I cannot get the output to go to the screen and output at same time. I've tried tee -a tee and a number of commands but the only way I can get it working is... (3 Replies)
Discussion started by: newbie2010
3 Replies

9. Shell Programming and Scripting

Help required with Stderr and tee command

Hello All, I have a requirement to redirect stdout and stderr to 'log' file and stderr alone to 'err' file. Can someone please help me with this? Thanks in advance (2 Replies)
Discussion started by: vikas_trl
2 Replies

10. UNIX for Beginners Questions & Answers

Using tee command with ablity to provide input for prompts

OS version: RHEL 7.4 Shell : bash I would like to capture command outputs using tee like # yum upgrade | tee yumupgradeLog But, if I use tee command, I cannot respond to prompts like Is this ok : during command execution as shown below. Is there a way I could use tee and still be able to... (4 Replies)
Discussion started by: kraljic
4 Replies
ARP2ETHERS(8)						      System Manager's Manual						     ARP2ETHERS(8)

NAME
arp2ethers - convert arpwatch address database to ethers file format SYNOPSIS
arp2ethers DESCRIPTION
arp2ethers converts file arp.dat in the current directory into ethers(5) format on stdout. Usually arp.dat is an ethernet/ip database file generated by arpwatch(8). The arpwatch daemon in Debian will create different arp.dat depending on its configuration. All of them will be available at /var/lib/arpwatch/. FILES
/var/lib/arpwatch - default directory for arp.dat arp.dat - ethernet/ip address database SEE ALSO
arpwatch(8), ethers(5), rarp(8), arp(8), BUGS
Please send bug reports to arpwatch@ee.lbl.gov. AUTHORS
Original version by Craig Leres of the Lawrence Berkeley National Laboratory Network Research Group, University of California, Berkeley, CA. Modified for the Debian Project by Peter Kelemen, with additions from Erik Warmelink. The current version is available via anonymous ftp: ftp://ftp.ee.lbl.gov/arpwatch.tar.gz This manual page was contributed by Hugo Graumann. ARP2ETHERS(8)
All times are GMT -4. The time now is 08:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy