07-09-2007
Varialble in pipelines
Hi,
As per shell docs because commands in pipelines are run as separate processes,
variables set in a pipeline have no effect on the parent shell
In the sample below I am unable to set variable in Proc1 so that I can see it in the main program
Is there any work around ?
Thanks
Zam
#!/bin/ksh
Proc1()
{
echo $MYVAR in Proc1
MYVAR=TRUE
echo line1
echo line2
}
### main body ###
export MYVAR=FALSE
Proc1|
while read line;do
echo $line
echo $MYVAR
done
5 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
howdy all,
i've been trying to find info on piping info between multiple commands from the command line, but i've been unable to find any examples of piping continuous data through a chain of commands. basically, i'm trying to parse data from the top command and send it out over udp to another... (1 Reply)
Discussion started by: ohhmyhead
1 Replies
2. UNIX for Dummies Questions & Answers
Now before this thread gets closed, please be aware this is not classwork or homework, I am trying to learn unix by myself, and have come stuck below. So it is a pointless to close this thread, as I am trying to improve my unix by asking advice from people. That is what I assume a forum is for!
... (1 Reply)
Discussion started by: Vn3050
1 Replies
3. UNIX for Dummies Questions & Answers
How would I combine commands in a pipeline to produce an alphabetized list of who's online at a particular moment?
Then:
How would I take that pipeline and turn it into a command called "whoison"? (1 Reply)
Discussion started by: greeky
1 Replies
4. Shell Programming and Scripting
What if you want to have just one single pipeline that will create a file (let's say x) and we want all the content from another file (we can call it y), one word per line? (7 Replies)
Discussion started by: sarahahah
7 Replies
5. Shell Programming and Scripting
Hello Experts,
Can anybody assist me in writing a code to do the following:
I have a file present in the same directory from where this cod would run. The content of the file would be as below:
Config Filename: config_details.txt
Format:
Server_prefix,IP_of_server,username, password,... (1 Reply)
Discussion started by: chetanojha
1 Replies
LEARN ABOUT OPENSOLARIS
times
times(1) User Commands times(1)
NAME
times - shell built-in function to report time usages of the current shell
SYNOPSIS
sh
times
ksh
times
DESCRIPTION
sh
Print the accumulated user and system times for processes run from the shell.
ksh
Print the accumulated user and system times for the shell and for processes run from the shell.
On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways:
1. Variable assignment lists preceding the command remain in effect when the command completes.
2. I/O redirections are processed after variable assignments.
3. Errors cause a script that contains them to abort.
4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a
variable assignment. This means that tilde substitution is performed after the = sign and word splitting and file name genera-
tion are not performed.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWcsu |
+-----------------------------+-----------------------------+
SEE ALSO
ksh(1), sh(1), time(1), attributes(5)
SunOS 5.11 15 Apr 1994 times(1)