SSH Scripting/Automation, How To?

From: Stefan (stefan_at_dragolov.com)
Date: 03/08/04


Date: 8 Mar 2004 09:59:55 -0800

I need to automate a connection from a Win2k machine to a Sun machine
over SSH.
The script should automatically log in (using a hard coded password),
execute various commands on the server. Some of the commands may
prompt the user, however, the script should handle this and
automatically respond to the prompts. Also, the script should return
some sort of error code if a command executed on the server is not
successful.

I can do this using Tera Term Pro which has its own macro/scripting
language. It allows you to automate login, to "wait" for a certain
prompt to appear on the server and then automate the response, and
also sets and error environment variable for error login.

Howerver, I need to do this using an SSH client and Tera Term Pro's
ssh version does not work with its scripting language.

Any ideas of what I can use to do this????
Here is an example of a script written in Tera Term Pro scripting
language. I need something that is very similar to this:

; Sample macro for Tera Term
; Telnet login

; open Tera Term
; command line = 'TERATERM myhost.mydomain' (telnet)
connect 'myhost.mydomain.com'

; set username
UsernamePrompt = 'login:'
Username = 'myusername'
PasswordPrompt = 'Password:'
Password = 'mypassword'

; login
wait UsernamePrompt
sendln Username

wait PasswordPrompt
sendln Password
; OK, auto login complete.

; Set up environment
wait 'Enter your area [ora]'
sendln 'ora'

; Set up development stage
wait 'Enter your development stage [devel]'
sendln 'devel'

; Select development account
wait 'Please select a development user: (DEV01-DEV40)'
sendln 'DEV24'

sendln 'cat hello_kitty.txt'
sendln 'exit'



Relevant Pages

  • Re: expect script doesnt pass graphics chars correctly
    ... My expect script needs to automate login to a terminal server which is ...
    (comp.lang.tcl)
  • Re: Newbie php problem
    ... The OP said that their script would send email without ... Another common way is that spam bots will hit commonly ... you betcha he would automate it soon enough. ...
    (alt.php)
  • Re: Newbie php problem
    ... The OP said that their script would send email without ... CAPTCHA images are hackable/readable by the bots, ... you betcha he would automate it soon enough. ... contact form could have anything to do with its action script. ...
    (alt.php)
  • Re: OO-COBOL for Unisys IX
    ... >>Our biggest problem is that our configuration management system has been ... >>scripted to automate a mainframe compile from a ... >> us to try to script that, then send the intermediate results up to the ...
    (comp.lang.cobol)
  • Re: Newbie php problem
    ... and the script only executes the mail function ... hidden field to prevent blank emails, but spambots pass common variable ... bots (form mail spam bots, ... you betcha he would automate it soon enough. ...
    (alt.php)