What's a script?
Carl Friis-Hansen
ubuntuuser at carl-fh.com
Sun Jul 12 23:06:14 UTC 2009
On Mon, July 13, 2009 00:37, Mark C. Miller wrote:
> I'm a newbie and know nothing about programming. Here's a line I grabbed
> from another thread
>
> quote
>
> Basically, stick your ssh commands in a script. Stick the script in the
> appropriate start up file.
>
> unquote
>
> What does the author mean by a "script"? Is this a particular
> programming language? Once you get it written, whatever you write it in,
> what would be the command to execute it, once I figured out what the
> "appropriate start up file" is?
>
> Sorry to be so basic, but right now if it doesn't have an interface, I
> know little about it. I'd like to change that.
I am on my way to bed now, but I will just give you a few words on your way.
A script is much like .BAT files in Windows. You write scripts with a
plain text editor like gedit if you want to work with a GUI editor. When
you have written a script you can make it executable by changing the file
permissions with for example nautilus file manager. When your script is
made execuatable, you can click on it to run it or you can create a
luncher, much like in Windows, so you can better control how it is run and
you can stuff it in a menu or put an icon in the top bar.
Have a look at some existing scripts on your computer.
Here is an example of one of my very simple scripts, which is called
run-labjack:
/////////////////////////////////////////////
#! /bin/sh
#
# By Carl Friis-Hansen June 2009
#
echo Starting Data logging with Labjack.
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cd labjack2
rm -f u3shmID.txt
sleep 1
echo starting u3driver
sudo ./u3driver.sh > /home/carl/labjack2/log_u3driver 2>&1
# sudo ./u3driver.sh
sleep 2
echo Initiating ljrun
# ./ljrun --config > /home/carl/labjack2/log_ljrun 2>&1 &
./ljrun --config > /dev/null &
sleep 4
echo Initiating monitor
./monitor > /home/carl/labjack2/log_monitor 2>&1 &
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo Done.
echo
/////////////////////////////////////////////
The very first line determines what interpreter/language is to be used.
In this case I have used the standard shell, like you would use CMD or
COMMAND.COM in Windows.
Hope I haven't scared you. There are tons of literature about writing
scripts for the standard batch processors.
--
---------=oOOo=---------
Carl Friis-Hansen
http://carl-fh.com/
Phone: +46 372 15033
---------=oOOo=---------
More information about the ubuntu-users
mailing list