How to Define Your Own System Command Scripts

The following uses the small, handy pico editor. Suppose that the command script you want to create is called zzz. Note that system scripts' names do not contain suffixes.
  • Open a konsole window.
  • Change to the ~/bin (i.e., /home/vunetid/bin) directory: cd ~\bin
  • List the ~/bin directory to see if a shell script named zzz is already present: ls
    • It's a good idea to check that the system doesn't already contain such a command: which zzz
  • If zzz is listed in the contents of the directory, open zzz in a text editor: pico zzz
    • If zzz is not present, open a new file to be named zzz in a text editor: pico zzz
  • Type the commands you want in your bash script. Use this as the first line of the file: #!/bin/sh
  • Exit pico by typing Ctrl+X to save the zzz file (answer Yes to saving changes, and keep the name of the file as zzz).
  • At the command prompt type the following to make zzz executable: chmod +x
  • Change your $PATH to include the ~/bin directory.
    • Change to your 'home' directory: cd ~
    • Open your .bash_profile (a hidden file) in a text editor: pico .bash_profile
    • In the text editor, type a new line at the end of the file: export PATH=$PATH:~/bin if this line is not already in .bash_profile
    • Exit pico by typing Ctrl+X to save your .bash_profile file (answer Yes to saving changes, and keep the name of the file as .bash_profile).

This topic: Main > DeptOps > DeptComputing > SystemScriptHowto
Topic revision: 18 May 2009, WillGray
 
This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback