|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
function GetInput
{ print -n "Input" read input export INPUT=$input } export COMMAND="GetInput" $COMMAND echo "$INPUT" $COMMAND | tee -a Log.log echo "$INPUT" The first one without "tee" works fine. echo "$INPUT" displays the values I type in for input. The second one always shows $INPUT as empty string. Why? Is there any other way to execute a shell function and capture its log output and at the same time display its output on the stdout device too without impacting its actual behavior? As you can see here, although the fucntion exports the variable INPUT, it is not available when the function call returns to the calling script code. Thanks for any help Hoping to ===> ![]() |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
Quote:
Quote:
Quote:
|
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Your comment "all commands except the last are executed in a sub-shell" explains the behavior, which is what I though though was not sure. What exactly is the "last one", the tee command itself, the rightmost one I guess? In my context, the command which I run and pipe the output to using tee is a "shell function" defined within the script - not a script different from the one that calls it. Usually functions run in the same shell as the one in which the script calling them runs. Including pipe seems to make a difference ot the bahavior. Thanks anyway for your time and effort in responding.
|
|
#4
|
||||
|
||||
|
Quote:
|
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Is there an alternative to "tee" with "pipeline" to capture outputs and at the same time view on the stdout device? Thanks again for the clear explanation, helped me a lot.
|
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
Quote:
|
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| recording command outputs in background | jehrome_rando | Shell Programming and Scripting | 2 | 02-16-2009 04:13 PM |
| Shell script outputs different results when commands are entered directly on the CL | atilano | UNIX for Dummies Questions & Answers | 3 | 02-01-2009 03:46 PM |
| What command or script to capture a system snapshot? | SecureMe | Security | 1 | 12-29-2008 05:40 PM |
| problems with a script that outputs data to a file | joeribut | Shell Programming and Scripting | 1 | 10-30-2008 12:54 PM |
| How to store the outputs of a shell script inside a log file??? | sunitachoudhury | Shell Programming and Scripting | 2 | 03-20-2008 05:45 AM |
|
|