Go Back

Running (and sourcing) UNIX shell scripts

Article Number: 1005
First Published:
Modified:
Recent Activity:
Views: 39
OS: Unix
Product: Synergy DBL, Operating System

When running a shell script on UNIX or Linux, the source keyword is used to run the script in the current process and omitted when you want to run the script in a new process that then immediately goes away.


For example, this executes the script in a new, temporary process:

myscript.sh


while this runs the script in the current process:

source myscript.sh


You can optionally use the dot command in place of source (the dot is just an alias for the source keyword):

.myscript.sh


The method you should use depends on what you are trying to accomplish. For example, if the script sets environment variables, you likely want to source it to make the environment variables available for the process you are going to run next. If the script contains the exit command, you may want to call the script without the source keyword/dot. 


For example:


../setsde will set environment variables for Synergy/DE in the current shell.


./install.sde will perform the installation in another shell and return to the originating shell when done.



THE INFORMATION PROVIDED TO YOU IN THIS SERVICE IS FOR YOUR USE ONLY. THE INFORMATION MAY HAVE BEEN DEVELOPED INTERNALLY BY SYNERGEX OR BY EXTERNAL SOURCES. SYNERGEX MAKES NO WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS INFORMATION, INCLUDING THE WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SYNERGEX BE LIABLE FOR ANY DAMAGES OR LOSSES INCURRED BY YOU IN USING OR RELYING ON THIS INFORMATION, INCLUDING WITHOUT LIMITATION GENERAL DAMAGES, DIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES, OR LOSS OF PROFITS, EVEN IF SYNERGEX HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Please log in to comment on this article.