Skip to Content.
Sympa Menu

baslinux - Re: [BL] Scripts with BL3

baslinux AT lists.ibiblio.org

Subject: Baslinux mailing list

List archive

Chronological Thread  
  • From: David Moberg <davidjmoberg AT gmail.com>
  • To: info AT freedomnet.org.uk, baslinux AT lists.ibiblio.org
  • Subject: Re: [BL] Scripts with BL3
  • Date: Sat, 10 Dec 2005 14:52:13 -0800

On 12/10/05, Ian <info AT freedomnet.org.uk> wrote:
> Hi, I need to learn a bit of scripting for BL3. Could someone please
> start me off. Im fairly ok with Dos batch files. Heres a sort
> of Dosish mixture that is supposed to toggle the mount/umount for
> my floppy drive. Wont work obviously.
>
> @echo off

bash or ash do not need echo off, it is off by default. In Linux,
shell scripts usually start with this line:

#!/bin/sh

This tells Linux to use /bin/sh to execute this file.

> if exist a:\null goto UNMOUNT

What is a:\null? Is it just an ordinary file on the floppy disk? If so,
this line will become:

if (test -f /mnt/floppy/null); then umount /dev/fd0; exit; fi

'test -f' checks if /mnt/floppy/null exists and is an ordinary file.
'exit' will stop execution in the middle of a shell script.
'fi' is equivalent to 'endif' in DOS.

A semicolon ';' behaves just like a new line, so this is really
four short lines squashed into one long line.

You can also umount /mnt/floppy instead of /dev/fd0.

> mount -t msdos /dev/fd0 /mnt/floppy

That needs no modifications.

> goto END
> :UNMOUNT
> umount /dev/fd0
> :END

You do not need this. Just three lines (6 if you count the
semicolons as new lines):

#!/bin/sh
if (test -f /mnt/floppy/null); then umount /dev/fd0; exit; fi
mount -t msdos /dev/fd0 /mnt/floppy

Remember to chmod +x the script file before you try to
execute it.

David




Archive powered by MHonArc 2.6.24.

Top of Page