| Author |
Message |
une

Joined: 26 Jan 2007 Posts: 56 Location: Australia
|
Posted: Tue 30 Jan 2007, 00:47 Post subject:
Bash shell scripting |
|
I want to teach myself shell scripting in BASH.
How do I find out which shell I am currently in (ASH or BASH) from the command line?
How do I swap shells?
What is the difference between ASH and BASH?
Are these the only two shells on Puppy LInux 2.13?
Is there a command that will list all available shells?
|
|
Back to top
|
|
 |
Gn2

Joined: 16 Oct 2006 Posts: 936 Location: virtual - Veni vidi, nihil est adpulerit
|
Posted: Tue 30 Jan 2007, 01:08 Post subject:
|
|
These are all generic Linux queries - use GOOGLE !
echo $ SHELL
bash - ash - sh , etc etc etc
Yes
As default included, Only two in Puppy
|
|
Back to top
|
|
 |
une

Joined: 26 Jan 2007 Posts: 56 Location: Australia
|
Posted: Tue 30 Jan 2007, 04:48 Post subject:
|
|
I tried to change shell using
# chsh
but received the message
sh: chsh: command not found
why did this not work?
I also tried
# echo $SHELL
and was told
/bin/sh
so I guess the sh is default shell in use.
When I look at the contents of /bin I see ash and sh are shown in light blue text and bash in lime green text. What do these colour differences represent?
|
|
Back to top
|
|
 |
trapster

Joined: 28 Nov 2005 Posts: 1966 Location: Maine, USA
|
Posted: Tue 30 Jan 2007, 06:44 Post subject:
|
|
ash is a symlink to busybox
sh is a symlink to bash
_________________ trapster
Maine, USA
Asus eeepc 1005HA PU1X-BK
Frugal install:Puppeee4.31 + 1.0, Puppy4.10 + Lupu52
Currently using Puppeee-1.0 AND lupu52 w/ fluxbox
|
|
Back to top
|
|
 |
une

Joined: 26 Jan 2007 Posts: 56 Location: Australia
|
Posted: Tue 30 Jan 2007, 08:04 Post subject:
|
|
Thanks. Does this mean symbolic links are shown in light blue text and actual applications shown in lime green text?
I don't know why chsh command did not work.
|
|
Back to top
|
|
 |
rarsa

Joined: 29 May 2005 Posts: 3053 Location: Kitchener, Ontario, Canada
|
Posted: Tue 30 Jan 2007, 10:21 Post subject:
|
|
| une wrote: | | I don't know why chsh command did not work. | First, I read that you said that you wanted to learn to script in bash, well, stick to bash, I don't know why you want to open another shell.
chsh didn't work because there isn't a chsh in Puppy. Really, when a command is not found its because it is not there.
Second:
Here is the best Bash tutorial I've ever seen. It may not be the most complete but after reading it you will feel quite comfortable writing and reading Bash scripts:
http://steve-parker.org/sh/sh.shtml
Third:
Consider that bash scripting is just a way to execute commands in a programmed sequence. So when scripting in bash you will most likelly need to learn those commands. Here is a list of commands that you will need to understand:
grep
sed
awk
cut
tr
Fourth:
Learn regular expressions. Puppy comes with a regular expresions evaluator under the Utilities menu so you can experiment with them.
I hope this helps
_________________ http://rarsa.blogspot.com Covering my eclectic thoughts
http://www.kwlug.org/blog/48 Covering my Linux How-to
|
|
Back to top
|
|
 |
une

Joined: 26 Jan 2007 Posts: 56 Location: Australia
|
Posted: Tue 30 Jan 2007, 19:23 Post subject:
|
|
Thanks for your detailed help. My understanding is minimal but I thought that every bash shell was the same, containing many commands and that every bash shell would have. When I type chsh at the command line on my Mandrake 10 Linux desktop system (using bash), the command is recognized. But on my Puppy system the same command is not found within bash. I now assume then that even within the same shell, the commands and functionality varies between systems as they may contain different versions of the same shell. Is this correct?
I don't particluarly want to change shell, but my experiments led to this discovery that does not make sense to me yet.
Is it also the case that sh and bash are different shells (but very similar) and that Puppy only has bash? Thus the symbolic link from sh to bash is present so that scripts that reference sh will work in Puppy's bash shell.
|
|
Back to top
|
|
 |
Gn2

Joined: 16 Oct 2006 Posts: 936 Location: virtual - Veni vidi, nihil est adpulerit
|
Posted: Tue 30 Jan 2007, 20:05 Post subject:
|
|
"sh" Is not a distinct Linux shell variant - & in Puppy - is a symlink to Bash !
Google for different Linux shells available , how they vary.
Bash is the default Linux command parser - it is backwards compatible in most cases - NOT all
As was explained, (by default) inclusion in Puppy has limited ash and Bash CLI parameters.
Temp shelve interest in other shells -concentrate on learning Linux basics & as need dictates, time permits, how to script using Bash.
Puppy forum is for distribution specific variations.
The best way to learn is by backing up (running in RAM mode obviates most full_install_to_hard drive concerns)
Then experiment - asking should be considered - as a last resort when unable to find resources, documentations.
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Tue 30 Jan 2007, 20:23 Post subject:
|
|
ash is a small inbuilt shell of busybox.
Busybox is used when Puppy boots, it allows to keep the initial ramdisk small.
Busybox is a binary, that includes several commands, that else are only available as seperate programs.
But this small size has a price: not the full set of options of these programs are available.
So when Puppy booted, it additionally offers the bash, that is loaded from the big file pup_2xx.sfs.
Bash compatibility is required by several programs.
Other shells like ksh or csh have specialized capabilities like support for mathematic functions.
You will find those on universitary systems.
We had one program once, that required csh, so you can extract it from this archive:
http://dotpups.de/files/unsorted-not-packaged/bsd-csh.tgz
The original limited sh is used no longer, as GN2 said, it usually is just a symlink to one of the others like the Bash (Bourne again shell), that has become quasi standard in Linux, as it is part of the GNU Utilities from the Free Software Foundation.
The FSF has rewritten several Unix-tools under a free license.
What we commonly know as "GNU/Linux" usually is the Kernel (the "real" Linux) plus the GNU Utilities like bash.
Mark
|
|
Back to top
|
|
 |
PaulBx1
Joined: 16 Jun 2006 Posts: 2308 Location: Wyoming, USA
|
Posted: Tue 30 Jan 2007, 21:10 Post subject:
|
|
Mark, thanks for your very clear synopsis here. I have seen the situation with Puppy's shells described here and there before, but usually in an unsatisfactory way that raised even more questions.
|
|
Back to top
|
|
 |
rarsa

Joined: 29 May 2005 Posts: 3053 Location: Kitchener, Ontario, Canada
|
Posted: Tue 30 Jan 2007, 22:56 Post subject:
|
|
| une wrote: | | I thought that every bash shell was the same, containing many commands and that every bash shell would have. | There is only one bash, there is no such thing as "every bash".
Now I understand your confusion a little bit better:
First
There are different shells, cshell, kornshell, bourne shell, bash. This link may clarify it
http://www.freeos.com/guides/lsst/ch01sec07.html
Second
Not every command that you execute in Bash is a bash command, some are external comands. For example, if you open a bash window and execute "geany" it will open, that does not mean that geany is a bash command, it means that bash executed that command.
chsh is an external command that changes shells,
http://www.die.net/doc/linux/man/man1/chsh.1.html
As puppy only comes with one shell, there is no need for that command.
| Quote: | | I now assume then that even within the same shell, the commands and functionality varies between systems as they may contain different versions of the same shell. Is this correct? | No, it is not correct.
As an example, every car has the same functionality, but if I put fuzzydice in one car, does not mean that all cars will have them, does it?
| Quote: | | Is it also the case that sh and bash are different shells | No, sh is not "a shell", it is a link to the default shell. So in puppy it is pointing to bash, in other systems it may be pointing to some other shell.
I hope this clarifies the issue.
_________________ http://rarsa.blogspot.com Covering my eclectic thoughts
http://www.kwlug.org/blog/48 Covering my Linux How-to
|
|
Back to top
|
|
 |
une

Joined: 26 Jan 2007 Posts: 56 Location: Australia
|
Posted: Wed 31 Jan 2007, 00:41 Post subject:
|
|
Thanks for such detailed responses. You have cleared up a lot of issues for me. It is much appreciated.
|
|
Back to top
|
|
 |
Gn2

Joined: 16 Oct 2006 Posts: 936 Location: virtual - Veni vidi, nihil est adpulerit
|
Posted: Wed 31 Jan 2007, 16:36 Post subject:
|
|
Just a note RE the supplied link Alternate shells:
Please be aware command {chsh} is used to alter default O/System LOGIN shell
That may not be advisable > ESP in Puppy
|
|
Back to top
|
|
 |
une

Joined: 26 Jan 2007 Posts: 56 Location: Australia
|
Posted: Thu 01 Feb 2007, 02:25 Post subject:
|
|
So it seems that the command chsh executes an application (if that application has been installed on the system) that changes the shell. This command does not execute a function built into the shell itself, unlike commands such as rm and grep. Do I have this much correct?
Sorry for not being distro specific, but I figure I may as well finish this thing now.
|
|
Back to top
|
|
 |
Flash
Official Dog Handler

Joined: 04 May 2005 Posts: 9844 Location: Arizona USA
|
Posted: Thu 01 Feb 2007, 09:47 Post subject:
|
|
No, don't stop now. This is a subject which has needed clarification for some time. I'm adding this thread to the Beginners sticky index, under Educational discussions. Thanks to everyone who contributed helpful explanations.
|
|
Back to top
|
|
 |
|