[raspberry-vi] Re: Auto-start shell/batch scripts on a pi?

  • From: Jeffery Mewtamer <mewtamer@xxxxxxxxx>
  • To: raspberry-vi@xxxxxxxxxxxxx
  • Date: Thu, 17 Nov 2016 17:59:24 +0000

Bash scripts are the Linux equivalent to batch files, and indeed, they
are named .sh by convention.

The basic structure of a bash script is:
#! /bin/bash
[commands to be executed]

and once saved and made executable, you can run them by typing
path/to/script.sh

at the command line. Do note that you will need to append ./ in front
of the script name to run a script in the working directory. E.g.:
./script.sh

As for python code, if you add
#! /usr/bin/python

or

#! /usr/bin/python3

to the top of a .py source file and make it executable, you can run it
without having to invoke the python or python3 command.

In general, if I'm not mistaken, adding

#! /path/to/interpreter

to the top of a source file and making it executable works for most
interpreted languages.

And while the how is beyond my current knowledge, it is possible to
build bash scripts featuring numbered menus that can be navigated both
with the arrow keys and pressing the number corresponding to menu
options. In fact, I'm fairly certain rassbpi-config is such a script.

-- 
Sincerely,

Jeffery Wright
President Emeritus, Nu Nu Chapter, Phi Theta Kappa.
Former Secretary, Student Government Association, College of the Albemarle.
=========================================================== 
The raspberry-vi mailing list 
Archives: //www.freelists.org/archives/raspberry-vi
Administrative contact: <mike.ray@xxxxxxxxxxxxxx>
-----------------------------------------------------------
Raspberry Pi and the Raspberry Pi logo are trademarks of the Raspberry Pi 
Foundation.

This list is not affiliated to the Raspberry Pi Foundation and the views and 
attitudes expressed by the subscribers to this list do not reflect those of the 
Foundation.

Mike Ray, list creator, January 2013

Other related posts: