I have a user that was having problems with a script. While looking at her script, I saw something odd that seems to work, but I'm not sure what it's doing.
From within one script, she's sourcing another using a dot. This is normal usage. What's odd is that she's put an ampersand at the end of the line to run it in the background. Sourcing is to run the commands in the called script in the same process that's calling it, but the ampersand is to force it into a background process.
I know it's a misuse of sourcing, but it seems to work. I told her to change the dot to "nohup", and that seemed to break it. This was due to other issues in the script, but I'm still curious about what exactly was happening process-wise.
Here's an example of what she's doing...
Any thoughts?
From within one script, she's sourcing another using a dot. This is normal usage. What's odd is that she's put an ampersand at the end of the line to run it in the background. Sourcing is to run the commands in the called script in the same process that's calling it, but the ampersand is to force it into a background process.
I know it's a misuse of sourcing, but it seems to work. I told her to change the dot to "nohup", and that seemed to break it. This was due to other issues in the script, but I'm still curious about what exactly was happening process-wise.
Here's an example of what she's doing...
Code:
#!/bin/ksh
. myscript.sh > myscript.log 2>&1 &