02-18-2004
Quote:
Originally posted by bensky
But it is still not clear for me why my old approach does not work.
The command:
show_menu
works the way you think it works. You invoked a function and the current shell can run it. When stop is changed inside the function, it affects the main shell's copy of "stop".
But:
show_menu | tee -a event.log
is a pipeline. Now a subshell must be spawned to run show_menu. And the function is changing the private version of "stop" in the subshell.
ksh is the only shell that I know that can run the last command of a pipeline in the current shell. This allows stuff like
echo hello | read variable
to work. But I don't know of any shell that can run the rest of a pipeline in the current shell.
See
this post for another approach.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Greetings to everybody. I would like to know if I can use the pipe and command tee to read from edited file and to write to him e.g. "sed '{s_A_B_}' file | tee file". :confused: I know it doesn't work with > but I don't know anything about it with tee. Thank you for your help. :) (1 Reply)
Discussion started by: Foxgard
1 Replies
2. UNIX for Dummies Questions & Answers
hello
how to append the hostname to each line of a file that is tee'd
for example:
tail -f file1 | tee file2
Iwant file2 to have the same new lines of file1 but with the hostname at the end or the beginning of each line.
btw, is there more proper method than: tail -f file1 | tee... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies
3. Shell Programming and Scripting
Hi,
I have a script where i want to log in details to the standard output as well as log file so that its easy for tracing purposes.
I have used the "tee"command.
The problem with this is my scripts lines are getting longer as for each line i have
#!/bin/ksh
echo "hello world" |... (4 Replies)
Discussion started by: pinnacle
4 Replies
4. Shell Programming and Scripting
Someone recently advised me to use the tee command to write to standard out.
Why would you pipe your commands to
tee -a <filename>
rather than just using
>> <filename>
?
For example:
date|tee -a myfile
seems to be the same as
date >> myfile
Is there a benefit to... (5 Replies)
Discussion started by: fracken_toaster
5 Replies
5. Shell Programming and Scripting
Hi,
When I run the following command in terminal it works. The string TEST is appended to a file silently.
echo TEST | tee -a file.txt &>/dev/null
However, when I paste this same line to a file, say shell1.sh, and use bourne shell .
I run this file in terminal, ./shell1.sh.
However I... (1 Reply)
Discussion started by: shahanali
1 Replies
6. Shell Programming and Scripting
I have been using the command tee to store the output to a file and also write on the terminal. However I would need to put the program in the background although I would still need to see the file being updated like it was doing when using tee.
Any suggestions on how to look at the log file... (3 Replies)
Discussion started by: kristinu
3 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I'm sure this is real simple but in the looking I've done I haven't seen it addressed (or didn't realize it). I've started up a PuTTY connection to our UNIX box and started screen and script - no problems. Then I typed "tee teeKH18.txt" expecting it to start tee and dump all activity into... (2 Replies)
Discussion started by: Mike Welch
2 Replies
8. Shell Programming and Scripting
Greetings!
My apologies if this has been answered elsewhere before. What I have is a function (as below) set up to append to either an error log or info log based upon input.
myLOGGER ()
{
if ]; then
logfile=$elog
lastERROR="$1" #used elsewhere in my script
else... (2 Replies)
Discussion started by: reid
2 Replies
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
I'm on Ubuntu 14.04 and I manually updated my coreutils so that "tee" is now on version 8.27
I was running a script using bash where there is some write to pipe error at some point causing the tee command to exit abruptly while the script continues to run. The newer version of tee seems to prevent... (2 Replies)
Discussion started by: stompadon
2 Replies