@vomv1988: Thank you for the explanation. You started an interesting thread, I would not say it is criticism, but rather some hopefully helpful comments. Regarding the parentheses in your original script, I was only referring to them because I think they are superfluous...
Yes, in a way, they are, and you are correct to state that the functionality of the original script is not altered by their absence. My intention in putting them there was only to emphasize how a child script (such as a background process, or a parenthesized section in a script) can pass data to it's parent.
I'm very glad you find the thread interesting, and I appreciate the multiple features of different shells you have provided.
EDIT:
Now that I take a good look at it, you're right! The background process...
...is already in a subshell!, so yes, the parentheses come out as completely superfluous... I get you now, loud and clear. In that sense, I guess you could say that the parentheses show that, no matter how deep the ancestry gets, the fifo will always be there to communicate all of it's levels.
---------- Post updated at 02:37 PM ---------- Previous update was at 02:04 PM ----------
Quote:
Originally Posted by Scrutinizer
Ok, here; what is the difference between using exec and doing...
...instead? I seem to get the same results with both. But you say that:
Quote:
Originally Posted by Scrutinizer
If you have more than one write statement, it is better to use exec, otherwise VARIABLE=`cat $TMPFIFO` goes on after the first command writes an EOF and the sub process will not finish.
What do you mean by "goes on after the first command writes an EOF"?
EDIT:
Unless you're talking about using exec instead of using redirection for each write statement (as opposed to for the whole curly braces, which is what I did here). For example, when I tried:
I got varying results for each time I ran it. Fifo redirection for each write statement malfunctions here.
EDIT2:
BTW, thanks for the tip on coprocesses, I've never really used them, or even heard about them before, but it's good to know that the option exists.
Hi,
I am running a series of scripts and I need to transport a particular variable across many scripts. I thougt of defining an environmental variable which I could access through. But I found that the variable dies as soon as the script ends..
Currently I write this variable to a temporary... (2 Replies)
I'm having an issue when I export within my program. I'm getting the variable name, not the variable value. I have a configuration file (config.txt) that has the values of the variables set as so:
set -a
export ARCHIVEPOSourceDir="/interfaces/po/log /interfaces/po/data"
export... (2 Replies)
I have always used the "$$" environment variable to find the current process number. Is there any similar way or perhaps something else to easily find the parent process number? I realize I could do something like ps and grep for the process and cut or awk out the parent process but I wanted to... (1 Reply)
hi experts(novice people can stay away as it is no child's game),
i am developing a script which works like recycle bin of windows.
the problem i am facing is that when ever i am trying to delete a file which is situated in parent directory or parent's parent directory i am unable to... (1 Reply)
Hi All,
I have a script which calls a child script with a parameter to be run in the background
. childscript.ksh $a &
Can any one suggest me how do i export a variable from the child script to parent script?
Note that the child script is in background
If the child script is in... (3 Replies)
Hi,
I have a number of Makefiles, including a couple of files that I include in Makefiles, a few scripts that are executed through Makefiles, and I have problems with environment variables that are not inherited to the scripts properly.
Simplified scenario:
rootdir/Makefile:
all:
... (1 Reply)
Hi,
I was trying to do something where I would be able to export one local variable in a telnet subshell to its parent shell.
I found something like this over here, but couldnt exactly understand it :(.
I am referring to this part actually:
#! /usr/bin/ksh
exec 4>&1
tail -5 >&4 |&
exec... (4 Replies)
I have a shell script I want to run that will set environment variables based on the value of an input variable submitted when the shell script is called. For example:
$ mgenv.sh prod
This would set environment variables for prod
$ mgenv.sh test
This would set environment variables... (1 Reply)
I'm a BASH shell user (relatively new)
I need to get a variable calculated in a subshell, outside the subshell, when it completes. I can do it, by writing the variable into a file, and then reading the file again when outside the subshell. I've tried lots of things from exporting to environmental... (3 Replies)
I have a simple script to log network connectivity to a set of systems.
However, as expected the date appended to the log never changes because the new variable is lost when the loop starts again. Can someone clue me in on how to get around this issue?
#!/bin/bash
LOG=/tmp/netlog... (3 Replies)