Unix Shell - How to continue after automated telnet session spawned

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > June 2006 > How to continue after automated telnet session spawned





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to continue after automated telnet session spawned
akarui.tomodachi@gmail.com

2006-06-08, 7:23 pm

A: Currently done:
1) I run an expect script from my desktop (using cygwin) to open
automated telnet session to a remote UNIX box.
2) That script opens the telnet session to the remote machine and sits
idle at the prompt waiting for the next command.

######### Here is the script #########
set timeout 1800

set TELNETHOSTNAME myRemoteMachine
set PAUSE 3

spawn telnet $TELNETHOSTNAME
sleep $PAUSE
expect "login: "#"
send "myUserId\r"
sleep $PAUSE
expect "Password: "
send "myPassWd\r"
sleep $PAUSE
interact
############### end of script #########

B: Next step (wish list):
1) After telnetting, I like to send an UNIX command to the remote box
(e.g. tail -f myLog.log > myFile.txt).

C: Question:
1) How can I do this automatically without typing on the prompt of the
remote box ?

Jordan Abel

2006-06-09, 1:31 am

akarui.tomodachi@gmail.com wrote:
> A: Currently done:
> 1) I run an expect script from my desktop (using cygwin) to open
> automated telnet session to a remote UNIX box.
> 2) That script opens the telnet session to the remote machine and sits
> idle at the prompt waiting for the next command.


Such a thing is likely to be very fragile. Whatever you're trying to
automate, you might want to use ssh instead.
Hubble

2006-06-09, 1:31 am


akarui.tomodachi@gmail.com schrieb:

>...
> 1) After telnetting, I like to send an UNIX command to the remote box
> (e.g. tail -f myLog.log > myFile.txt).
>
> C: Question:
> 1) How can I do this automatically without typing on the prompt of the
> remote box ?


By using send. First set the prompt, so that you can expect the end.
Assuming the remote shell is sh/bash/ksh, use

send PS1="+++Ready.+++\r"
expect "+++Ready.+++"
send "tail -f myLog.log > myFile.txt\r"
expect "+++Ready.+++"

instead of interact

Hubble.

Steven Ding

2006-06-10, 7:25 am

Jordan Abel ??:
> akarui.tomodachi@gmail.com wrote:
[vbcol=seagreen]
>=20
> Such a thing is likely to be very fragile. Whatever you're trying to=20
> automate, you might want to use ssh instead.

Any indications on ssh automation?

wjding<at>gmail<dot>com
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com