User Tools

Site Tools


wiki:2018introduction_to_scripting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
wiki:2018introduction_to_scripting [2018/09/04 08:45]
david [Interactive exercise]
wiki:2018introduction_to_scripting [2018/09/04 08:58] (current)
david
Line 184: Line 184:
 Hello World Hello World
 </​code>​ </​code>​
 +
 +==== which ====
 +
 +To see if a command actually a program in your path, do
 +<code bash>
 +$ which programname
 +$ which ls
 +/usr/bin/ls
 +</​code>​
 +
 +Try it with some other commands.
 +
 +You'll see that they tend to be in only a handful of directories. When programs are installed on a computer, they are automatically put in a central location. These directories serve that purpose on UNIX/linux.
  
 $PATH is an **environmental variable**, like $USER, that is set during login. Some important environmental variables are: $PATH is an **environmental variable**, like $USER, that is set during login. Some important environmental variables are:
Line 204: Line 217:
  
 The second method is to make it easier to run programs- otherwise you'd have to type in the full path of ''​ls''​ every time you needed to run it. The other is so you don't accidentally run malicious or unintended code. The second method is to make it easier to run programs- otherwise you'd have to type in the full path of ''​ls''​ every time you needed to run it. The other is so you don't accidentally run malicious or unintended code.
- 
-==== The full path of ls ==== 
- 
-To see if a command actually a program in your path, do 
-<code bash> 
-$ which programname 
-$ which ls 
-/usr/bin/ls 
-</​code>​ 
- 
-Try it with some other commands. 
- 
-You'll see that they tend to be in only a handful of directories. When programs are installed on a computer, they are automatically put in a central location. These directories serve that purpose on UNIX/linux. 
  
 ==== Amending the PATH variable ==== ==== Amending the PATH variable ====
Line 301: Line 301:
  
 This will be executed every time you log in. This will be executed every time you log in.
 +
 +== source ==
  
 In general, to execute commands into your current shell from a file, such as ''​.bash_profile'',​ do In general, to execute commands into your current shell from a file, such as ''​.bash_profile'',​ do
Line 307: Line 309:
 </​code>​ </​code>​
  
-This reruns (re-//​source//​s) your configuration file, and prints out messages as though you have logged in again.+This reruns (re-//​source//​s) your configuration file, and prints out messages as though you have logged in again. You can't //run// a script to effect your current environment. You have to ''​source''​ it.
  
 ====== EXTRA ====== ====== EXTRA ======
wiki/2018introduction_to_scripting.txt ยท Last modified: 2018/09/04 08:58 by david