fir3net
PPS-Firenetbanner-780.5x190-30-03-17

Bourne - Different ways to execute a script

1. The following 2 types of syntax are both ways to execute a script. Using these methods a second shell will be opened and once the script has finished the variables will not persist.

chmod +x [script]
sh [script]

2. Below shows you a way in which you can run your script using the current shell, and once the script has finished the variables will persist.
This would be useful in a scenario when you were making changes to your profile variables and wanted to activate the changes without logging off.

. [script]

3. The final way terminates you current shell, and spawns a new shell in order to run the script. Once the script has completed the user will be logged off.
This can be useful to isolate and restrict certain users and their profiles.

exec [script]

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001