|
||||||||||||||||||||||||||||||||||||||||||||||
| ISBN: 3937514872 ISBN: 3937514872 ISBN: 3937514872 ISBN: 3937514872 | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
Wir empfehlen: | |||||||||||||||||||||||||||||||||||||||||||||
A free Basic UNIX-training with muLinuxTo save this lesson onto a floppy-disc, we insert a floppy into the floppy-drive, mount the device to /a./# mount /dev/fd0 /a /#
The standard commands offered by a Unix such as muLinux are much more comprehensive than the commands offered in DOS. Many tasks that need different DOS programs to do can be executed without any problems in a few Unix commands. And above that, individual commands can be combined in script-files, which are comparable with Batch-files in DOS. Because of that much more comprehensive language, and the flexibility offered by shell scripts, it is a much more comfortable environment to program in. In a way Unix commands can be used as modules for more extended tasks, so many things don't need to be programmed from the beginning (like in DOS). And finally, under X-Windows, these scripts can be used to adding some graphical skin to the bones of the shell (X-Windows is a graphical environment for Unix, and is on one of the muLinux add-on disks).
|
||||||||||||||||||||||||||||||||||||||||||||||
clear df ~ ~ ~ ~ ~ ~ ~ ~ ~ "test" [New File] 2 lines, 9 chars |
We save our work and leave vi:
[Esc] :wq
Now comes the second step. We need to make our file executable, so that users can run it. By using ls -l we can see that the file isn't yet an executable. If we go ...
/a/bin# chmod u+x test
The file is now executable. We can check this with ls -l:
/a/bin# ls -l test 1 -rwr--r-- 1 root root 9 Nov 17 17:59 test
The x shows us that we as a user have the permissions to execute this file. And this is what we are gonna do:
/a/bin# ./test The output of df: all mounted devices and the space-information on it.
The dot defines the parent working directory. We also can execute the command like this:
/a/bin# /a/bin/test
[Alt] [F2]
Also there we log in as root and fire up the text editor vi:
login: root /# cd /a/bin /a/bin# vi test
So, now we can edit on the second console our script, save it ([Esc] :w) and change to console 1 ([Alt] [F1]) to execute it. For that we use again the repeat-command feature of Unix (Cursor-up). To continuing editing we return to console 2 ([Alt] [F2]).
Leave this blank # This is a comment-line! clear df ~ ~ ~ ~ ~ ~ ~ ~ |
# This is a comment-line! clear echo " info about the mounted devices:" df ~ ~ ~ ~ ~ ~ ~ |
echo Without parameters this outputs a empty line. But we can format our script to get our output a bit fancier.
# This is a comment-line! clear echo echo "info about the mounted devices:" df echo ~ ~ ~ ~ ~ |
# This is a comment-line clear echo echo "info about the mounted devices:" df $* echo ~ ~ ~ ~ ~ |
Now we can execute our script with parameters. The parameter /a shows us the info about the mounted device mounted on mountpoint /a
/a/bin# ./test /a
The parameters /a and /tmp show us the info about the devices mounted on these mountpoints.
/a/bin# ./test /a /tmp
There can also be given special devices as parameters.
/a/bin# ./test /dev/ram0 /dev/ram1
Hint: the floppy can't be mounted while it is being formatted! And please don't format either your work floppy or your muLinux bootdisc. And finally a copy of the error-free script should be put onto your work floppy.
So, this is it for now with shell-scripts.
To finish this lesson we unmount our
work floppy.
/a# cd /
/# umount
/a
/#
|
Ubuntu & Kubuntu Linux 9.04 "Jaunty Jackalope". Doppel-DVD mit Ubuntu und Kubuntu 9.04 als Live- und Vollversionen, inkl. Einsteiger-Handbuch von Open Source Press | |
| Siehe auch: | |
![]() | |
| Ubuntu 9.04 Jaunty Jackalope: Das Einsteigerbuch | |
| Ubuntu GNU / Linux: Das umfassende Handbuch, a... | |
| Linux lernen mit Ubuntu | |
| Ubuntu & Kubuntu Linux 9.10 "Karmic Koala" (Doppel-DVD inkl. Han... | |
| Ubuntu 9.10 Karmic Koala: Das Einsteigerbuch | |
| Einstieg in Linux: Eine distributionsunabhän... | |