Newbie to terminal scripting

Matsaki

Registered
I want to make some automation in the terminal.

I.e login to a remote server with username and password

and

run a telnet login to my dreambox and run some UNIX commands.

Where shall I start, I meen what method should I use, and please if there is some simple tutorials to make some study.

Thanks!
 
- Make your script in a text editor, such as TextEdit. Unix purists will argue the merits of vi or pico, which are accessed through the terminal, but this is not very helpful for beginners.
- A script will be a series of unix commands strung together in the order you want to run them.
- You would be very wise to pick up a book on Unix/Linux from your local library and read up a bit on shell scripting. A good textbook on bash, csh, tcsh, ksh, etc would be the easiest way to learn a scripting language.
 
A nice tutorial is found here: http://www.informit.com/articles/article.asp?p=350778&seqNum=6

Now, in 'Terminal' you can write 'man ssh' and 'man telnet' and get a lot of information about these commands. You can use the up and down arrow keys to scroll line-by-line and [space] and to scroll page-by-page; to exit an 'man' type [q]

But to dwelve deeper into the stuff you'll need real books. I can recommend the following ones:
http://www.oreilly.com/catalog/bash3/
http://www.oreilly.com/catalog/shellsrptg/
http://www.oreilly.com/catalog/sshtdg2/
 
Scripting with sh is useful to know, but I really never use more than the most simple aspects because almost every UNIX-type machine has the perl language installed. Perl is a scripting language that was invented to be kind of a combination of the best parts of many different script languages. For me I write 90% or more of my scripts in perl because it is so much more flexable than the other languages.

When you wrote that you want a script to login to a remote machine -- this is a little more difficult of task. Depending on what you want to do on the remote machine there are many different ways to approach the problem. The languages sh and perl might not be the best method to do this.

Finally you should be careful with telnet. It is a big security problem because passwords are sent in the clear. I would suggest that you consider using ssh (secure shell) instead of telnet. Ssh operates just as telnet does, however the passwd is sent encrypted.
 
Hehe,
Thanks guys, but that was much harder then I thought. I don't think I am ready to spend all that time learning this.

But thanks anyway :)
 
I would definitely go with ssh when going to other machines...if you do the ssh keygen thing you can create keys so you won't have to punch in the p/w each time. With ssh you can run commands (or scripts) on the remote server.

But yeah, you're going to want to learn a little bash, perl, etc.

Dale
 
Back
Top