Korn shell (ksh), a command-line interface for Unix. The main advantage of ksh over the traditional Unix shell is in its use as a programming language. Since its conception, several features were gradually added, while maintaining strong backwards compatibility with the Bourne shell.
IBM has published Korn shell scripting – A beginner’s guide:
Korn shell scripting can save you a lot of time and make your job so much easier. It can seem intimidating at first, but remember to always start out simple and build upon each and every script. Always follow the same steps: build your script header, define your variables, and error check your work. You just might find yourself trying to write a script for everything you do.
Korn shell scripting is something all UNIX users should learn how to use. Shell scripting provides you with the ability to automate many tasks and can save you a great deal of time. It may seem daunting at first, but with the right instruction you can become highly skilled in it. This article will teach you to write your own Korn shells scripts.
Razvan talk about hooking Amarok to MySQL database server and create an MP3 file server. I this is an excellent hack:
When it comes to playing music in Linux, Amarok is one of the best audio players out there. It offers almost everything you need, from a clean, intuitive interface to a range of useful scripts. You can even put it on a server and give it a Web interface.
ObsidianMusic was previously known as amaroK Web Frontend. It is a collection of scripts that, combined with a MySQL database and the Amarok player, forms an excellent way of sharing MP3 files over the Internet or a small office network. All the music files in your collection can be played, downloaded, or streamed by a regular Web browser. Furthermore, ObsidianMusic offers search capabilities and music sorting, and can be customized using themes.
=> Create an MP3 file server using Amarok and ObsidianMusic
This article examined a simple, but powerful, method to run commands on a remote machine using combination of ssh and a shell script:
Use Secure Shell (SSH) to run commands on remote UNIX systems and, with some simple scripts, put together a system that enables you to manage many systems simultaneously from one machine without having to log in directly to the machines themselves. Also examine the basics of a distributed management system and some scripts and solutions using the technique.
I have already covered how to execute commands on multiple Linux or UNIX servers via a shell script. The disadvantage of shell script is commands do not run in parallel on all servers. However, several tools exist to automate this procedure in parallel. With the help of tool called tentakel (highly recommended) , you run distributed command execution. Also, you can execute commands on multiple Linux or UNIX servers using special tools such as multixterm from expect project.
=> Distributed administration using SSH
When invoked without arguments, the date command displays the current date and time. Depending on the options specified, date will set the date and time or print it in a user defined way. I’ve seen many sysadmin writing perl scripts for calculating relative date such as yesterdays or tomorrows day. You can use GNU date command, which is designed to handle relative date calculation such as:
- 1 Year
- 2 Days
- 2 Days ago
- 5 Years
[click to continue…]
You may have noticed that most shell and perl script starts with the following line:
It is called a shebang. It consists of a number sign and an exclamation point character (#!), followed by the full path to the interpreter such as /bin/bash. All scripts under UNIX and Linux execute using the interpreter specified on a first line.
However there is a small problem. BASH or Perl is not always in the same location (read as PATH) such as /bin/bash or /usr/bin/perl. If you want to make sure that script is portable across different UNIX like operating system you need to use /usr/bin/env command.
env command allows to run a program in a modified environment.
For example here is a small script:
echo "$x and $y"
print "Hello " x 5;
Now you don’t have to search for a program via the PATH environment variable. This makes the script more portable. Also note that it is not foolproof method. Always make sure you have /usr/bin/env exists or use a softlink/symbolic link to point it to correct path. And yes your work (script) looks more professional with this hack :)