Sponsored Content
Full Discussion: How to get started with Unix
Top Forums Shell Programming and Scripting How to get started with Unix Post 302683491 by itkamaraj on Wednesday 8th of August 2012 06:08:08 AM
Old 08-08-2012
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how do i get unix started

i am a total newbie...and want to learn unix....firstly...how do i get unix....if it is available on the internet then where is it?...and how do i get this to work then.....plz plz help asap...really desperate now thanx in advance (10 Replies)
Discussion started by: chaitanyamanot
10 Replies

2. UNIX for Dummies Questions & Answers

Help getting started

Dear all, I just found out that my company is thinking of installing a unix server and is considering either sun or ibm. The thing is that i want to learn these two systems before they take a decision and maybe it will be a big career booster. The problem is that i don't know anything about... (7 Replies)
Discussion started by: patslaiby
7 Replies

3. UNIX for Dummies Questions & Answers

Getting started with VPS management through UNIX

Hi everybody, I have a VPS account and I have hit my limit for domains to manage through Plesk. I now need to begin administering new domains through UNIX. I've never used UNIX before but do have some experience with command line environments. I was able to connect today (I think). So the next... (1 Reply)
Discussion started by: snarky
1 Replies

4. UNIX for Dummies Questions & Answers

Getting Started with Unix

I am new to Unix and want to learn it thoroughly. From where can I download books/e-books and tutorials for free of charge:confused: (2 Replies)
Discussion started by: indiansoil
2 Replies

5. UNIX for Dummies Questions & Answers

Getting Started with Unix....

Hi all I'm a beginner in Unix world.I want to know from where i should start Book,E-Book.web site ,...etc by the way how many version does unix have? i should install which version? How to install it? and very important,is there any simulator for training purpose? for example can i install unix... (2 Replies)
Discussion started by: ZarrinPour
2 Replies

6. OS X (Apple)

I'm new and I am trying to get started with OS-X

I bought my first Mac a year ago December, and I love it. I have been interested in trying to write my own programs and don't even know where to start. I have never written any software before and was wondering if anyone could give me some recommendations on any books or other good websites that... (2 Replies)
Discussion started by: LittleWoman815
2 Replies

7. UNIX for Dummies Questions & Answers

getting started

hi world, I am trying to learn how to program in c, I've gotten a few books and have been reading them, one even came with bloodshed dev-c compiler, it is not working, every time I build the hello world program it always comes back saying " G__~1.EXE: installation problem, cannot exec `cpp': No... (1 Reply)
Discussion started by: jsayres
1 Replies

8. Solaris

Getting Started in UNIX - incorporating C coding

I'm just starting a 'serious' coding in UNIX, so what I need is to run a C code on UNIX, What do I have to install (app) prior to coding/running the code and how do I compile that code? can I write my c code in UNIX or I need to have a visual studio for this? (7 Replies)
Discussion started by: Peevish
7 Replies

9. Shell Programming and Scripting

Just started using UNIX, im at the basics and my scripts broken.

echo "Hi $username, guess what my favourite colour is!" count=0 while ] do read colour if then $count=1 echo "See ya later!" elif then $count=1 echo "You guessed correctly! Great job!"... (6 Replies)
Discussion started by: solomonsnare
6 Replies

10. What is on Your Mind?

Just getting started with UNIX programming and administration

Hi everyone, I am new to this forum and this is my very first post, one i think i will look back at many years from now and have nothing to regret about. This is simply because i recently installed Linux (Ubuntu) on my system and downloaded a book titled, The Unix Programming Environment. I... (7 Replies)
Discussion started by: despiragado
7 Replies
Net::CLI::Interact::Manual::Tutorial(3pm)		User Contributed Perl Documentation		 Net::CLI::Interact::Manual::Tutorial(3pm)

NAME
Net::CLI::Interact::Manual::Tutorial - Guide for new users Introduction Automating command line interface (CLI) interactions is not a new idea, but can be tricky to implement. Net::CLI::Interact aims to provide a simple and manageable interface to CLI interactions, supporting: o SSH, Telnet and Serial-Line connections o Unix and Windows support o Reusable device command phrasebooks The module exists to support developers of applications and libraries which must interact with a command line interface. The SYNOPSIS section of Net::CLI::Interact has an overview of the commands demonstrated in this document. Getting Started Like many other Perl modules, you need to load the library and then create a new Net::CLI::Interact instance (which is $s in the example, below): use Net::CLI::Interact; my $s = Net::CLI::Interact->new({ transport => 'Serial', personality => 'cisco', }); Your application can have multiple independent instances (that is, connect to different devices at the same time); simply repeat the above example more times for variables other than $s. Note that at the time you create the instance, as in the example above, the library does not connect to the device. That comes later. There were two options provided to the "new" call, above, both of which are required for all new instances. Let's look at them in turn: transport How do you want to connect to your CLI? The current choices are Telnet, SSH and a Serial line (that is, a console cable). In this option you need to tell the library which underlying transport is to be used. Some of the transports have additional options that are either required, or optional. For example, the Telnet and SSH transports both need to know which post name or IP address should be contacted. You pass this in another option to "new", like so: my $s = Net::CLI::Interact->new({ transport => 'Telnet', connect_options => { host => 'my.server.example.com' }, personality => 'cisco', }); See the manual page of the transport module for the option details. personality What language does the connected device speak? For instance one common format is Cisco's IOS, which is widely cloned on other vendor equipment CLIs. In this option you need to pass the name of a personality that's used to load a Phrasebook. A phrasebook is simply a library, or dictionary, of pre-configured phrases you can use on the CLI. This makes life simple, because Net::CLI::Interact then can automate some of the more difficult tasks. For example, if you issue a command and the output is "paged" so you hit Space or Return to see the next page, the phrasebook can tell Net::CLI::Interact how to slurp all these pages into one body of output before returning it to you. See the Phrasebook user guide for a list of the possible values for the "personality" option. Connecting This is done automatically for you the first time you send a command to the device, so skip this step and move on! Sending Commands But first, Prompts The idea of sending a command is, usually, to see some output. The most important part of this process is knowing when the output has all been sent, otherwise the library would sit forever, waiting to gather more text! Between each command sent, the connected device prints a CLI Prompt. This prompt is where you type commands, and it's what tells us that all the output has been sent from our last command. Prompts are loaded in the phrasebook, and given friendly names. If your personality's phrasebook is sufficiently mature, then the prompts might be fully automated, and just like the Connecting step above, you can skip doing anything manually. Consult the Phrasebook user guide for details. However if you need to set it manually, do the following: $s->set_prompt('friendly_name'); Sometimes you might not know what state the CLI is in; typically this applies to Serial lines. In that case you can ask to find the matching prompt: $s->find_prompt('wake_up'); The option "wake_up" asks to "hit the Return key", to make the device spit out its prompt. That is only done if needed, and you can remove "wake_up" to skip this step. Literal Commands There's not a lot to it. Remember that with a mature personality loaded, you were probably able to skip the previous prompt step and go straight to: my $output = $s->cmd('show ip interfaces brief'); Here you will get all the output from the command together in one variable, $output. If you prefer an array where each item is one line of output, simply use @output instead in the above example. Macros Life gets more complicated when your command has things like confirmation steps (e.g. reboot), other prompts (e.g. extended ping), etc. For these situations we have Macros in the phrasebook. A macro is simply a sequence of commands we could issue using "$s->cmd()", bundled together and given a friendly name. Macros are also smart enough either to handle simple confirmation steps themselves, or to allow you to pass in parameters. Some examples probably help: # saves config, accepting the default "startup-config" when prompted $s->macro('write_mem'); # logs in, passing a username and password at the prompts $s->macro('to_user_exec', { params => ['my_username', 'my_password'], }); # simply a parameterized command $s->macro('show_interfaces_x', { params => ['GigabitEthernet 3/4'], }); Slurping Output As mentioned above, output at the CLI is often "paged" with the user hitting Space or Return to show the next page. Most macros can deal with this automatically if well implemented. If the Phrasebook user guide says your personality has a named default Continuation for handling paged output, then set it like so: $s->set_default_continuation('friendly_name'); Disconnecting This is nothing more fancy than issuing the appropriate CLI commands to close the network connection. In the case of the Serial line transport you can usually only log out, and not fully disconnect. Simply end your application and the library will tidy things up as best it can. perl v5.14.2 2012-06-12 Net::CLI::Interact::Manual::Tutorial(3pm)
All times are GMT -4. The time now is 09:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy