Telnet script

2007-12-25 11:54:00

My question:

>

> Would you so kind to help me?

> I need information about telnet scripts under Solaris.

> I want to run some command on remote machine by local crontab.

> Where can get some examples on this topic?

>

Many THANKS to all replied!

Almost all advise to use rsh(ssh) or rexec.

But I didn't wrote that my remote machine is CICSO router

with only telnet service.

And only way I like & use is 1) way ( `sleep` is main in this pipe!,

I tried before without it ).

Summary of all ways is:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1)

From: steve@peachy.com

Here's one I use for telnetting to a different box and changing the password

there.

Telnets to host mickey, logs in as user001, password abc123, changes the

password to xyz123.

#!/bin/sh

( echo user001

  sleep 2

  echo abc123

  sleep 2

  echo id

  sleep 2

  echo passwd

  sleep 2

  echo abc123 sleep 2

  echo xyz123

  sleep 2

  echo xyz123

  sleep 2

  echo logout ) | telnet mickey

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

2)

From: np@bsn.com (Norbert Poellmann)

Try netcat (from netcat.blurb):

Netcat 1.10 is an updated release of Netcat, a simple Unix utility which reads

and writes data across network connections using TCP or UDP protocol. It is

designed to be a reliable "back-end" tool that can be used directly or easily

driven by other programs and scripts. At the same time it is a feature-rich

network debugging and exploration tool, since it can create almost any kind of

connection you would need and has several interesting built-in capabilities.

Some of netcat's major features are:

        Outbound or inbound connections, TCP or UDP, to or from any ports

        Full DNS forward/reverse checking, with appropriate warnings

        Ability to use any local source port

        Ability to use any locally-configured network source address

        Built-in port-scanning capabilities, with randomizer

        Built-in loose source-routing capability

        Can read command line arguments from standard input

        Slow-send mode, one line every N seconds

        Hex dump of transmitted and received data

        Optional ability to let another program service established connections

        Optional telnet-options responder

A very short list of potential uses:

        Script backends

        Scanning ports and inventorying services, automated probes

        Backup handlers

        File transfers

        Server testing, simulation, debugging, and hijacking

        Firewall testing

        Proxy gatewaying

        Network performance testing

        Address spoofing tests

        Protecting X servers

        1001 other uses you'll likely come up with

Netcat and the associated package is a product of Avian Research, and is freely

available in full source form with no restrictions save an obligation to give

credit where due. Get it via anonymous FTP at avian.org:/src/hacks/nc110.tgz

which is a gzipped tar file and not to be confused with its version 1.00

precursor, nc100.tgz. Other distribution formats can be accomodated upon

request. Netcat is also mirrored at the following [faster] sites:

        zippy.telcom.arizona.edu:/pub/mirrors/avian.org/hacks/nc110.tgz

        ftp.sterling.com:/mirrors/avian.org/src/hacks/nc110.tgz

        coast.cs.purdue.edu:/pub/tools/unix/netcat/nc110.tgz

        ftp.rge.com:/pub/security/coast/mirrors/avian.org/netcat/nc110.tgz

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

3)

From: Jeff Graham <demit@best.com>

Find a scripting language called "expect" Expect is used for

interactive sessions like the telnet scripting you want to do. You can

also use the perl module Expect.pm to get that functionality in perl.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

4)

From: "Robert L. Harris" <Robert.Harris@gwl.com>

You'll need to use either expect or perl with the net::telnet module.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Comments

Got something to say?

You must be logged in to post a comment.