For Programmers: Free Programming Magazines  


Home > Archive > Tcl > May 2007 > expect: ssh & screen parameters









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 expect: ssh & screen parameters
nickforpresident@gmail.com

2007-05-21, 7:10 pm

I'm using a little expect script to log into a router via SSH, and run
a command (via cron). This router detects the SSH client's screen
size, and only sends screenfulls of data at a time, followed by:

--More-- (q) quit (u) pageup (/) search (n) repeat

at the bottom of each screen. How can I run expect and make it use ssh
in VT100 or similar mode?

Any ideas or pointers in the right direction are greatly appreciated.

Why Tea

2007-05-22, 8:08 am

On May 22, 12:15 am, nickforpresid...@gmail.com wrote:
> I'm using a little expect script to log into a router via SSH, and run
> a command (via cron). This router detects the SSH client's screen
> size, and only sends screenfulls of data at a time, followed by:
>
> --More-- (q) quit (u) pageup (/) search (n) repeat
>
> at the bottom of each screen. How can I run expect and make it use ssh
> in VT100 or similar mode?
>
> Any ideas or pointers in the right direction are greatly appreciated.


Not too sure about your problem. But I guess you probably have
problems
seeing the expected text as you need to hit "u" to see it. If that's
the case, you can always add a line to detect it in your expect loop.
E.G.
expect {
"login name: " {
...
}
"assword: " {
...
}
"--More-- (q) quit (u) pageup" {
send u\r
continue
}
}

nickforpresident@gmail.com

2007-05-22, 7:12 pm

On May 21, 11:34 pm, Why Tea <ytl...@gmail.com> wrote:
> On May 22, 12:15 am, nickforpresid...@gmail.com wrote:
>
>
>
>
>
> Not too sure about your problem. But I guess you probably have
> problems
> seeing the expected text as you need to hit "u" to see it. If that's
> the case, you can always add a line to detect it in your expect loop.
> E.G.
> expect {
> "login name: " {
> ...
> }
> "assword: " {
> ...
> }
> "--More-- (q) quit (u) pageup" {
> send u\r
> continue
> }
> }


If I run the command logged into the shell, I never see the the --
More-- option. This started happening when I added the expect script
to run from cron. Also, when running from cron it only gives me 1 line
of output before that --More-- thing happens. I guess the router is
detecting the screen size of the connecting machine and outputting
accordingly. Any suggestions on how to "fool" the remote router?

Thanks

Mark Janssen

2007-05-22, 7:12 pm

On 22 May 2007 06:34:54 -0700, nickforpresident@gmail.com wrote:

>On May 21, 11:34 pm, Why Tea <ytl...@gmail.com> wrote:
>
>If I run the command logged into the shell, I never see the the --
>More-- option. This started happening when I added the expect script
>to run from cron. Also, when running from cron it only gives me 1 line
>of output before that --More-- thing happens. I guess the router is
>detecting the screen size of the connecting machine and outputting
>accordingly. Any suggestions on how to "fool" the remote router?
>
>Thanks


For cisco routers, a:

terminal length 0

should disable the --More-- prompt alltogether. In that case you don't
need to handle the 'More' case anymore.

Mark
nickforpresident@gmail.com

2007-05-22, 7:12 pm

On May 21, 11:34 pm, Why Tea <ytl...@gmail.com> wrote:
> On May 22, 12:15 am, nickforpresid...@gmail.com wrote:
>
>
>
>
>
> Not too sure about your problem. But I guess you probably have
> problems
> seeing the expected text as you need to hit "u" to see it. If that's
> the case, you can always add a line to detect it in your expect loop.
> E.G.
> expect {
> "login name: " {
> ...
> }
> "assword: " {
> ...
> }
> "--More-- (q) quit (u) pageup" {
> send u\r
> continue
> }
> }


If I run the command logged into the shell, I never see the the --
More-- option. This started happening when I added the expect script
to run from cron. Also, when running from cron it only gives me 1 line
of output before that --More-- thing happens. I guess the router is
detecting the screen size of the connecting machine and outputting
accordingly. Any suggestions on how to "fool" the remote router?

Thanks

nickforpresident@gmail.com

2007-05-22, 7:12 pm

On May 22, 10:19 am, Mark Janssen <mpc.jans...@gmail.com> wrote:
> On 22 May 2007 06:34:54 -0700, nickforpresid...@gmail.com wrote:
>
>
>
>
>
>
>
>
>
>
>
> For cisco routers, a:
>
> terminal length 0
>
> should disable the --More-- prompt alltogether. In that case you don't
> need to handle the 'More' case anymore.
>
> Mark


Unfortunately, for more reasons than this, this isn't a cisco box.
When cron executes the expect script, the remote device only thinks I
have one line to work with. But when I run it manually from the shell
(bash), it gives me all the space I need... Is there an environment
variable maybe that's controlling this? I'm trying to script expect to
login to the router, run a couple commands, and output the results to
a file. Thanks for your suggestions so far.

Cameron Laird

2007-05-22, 7:12 pm

In article <1179856603.509528.52830@q66g2000hsg.googlegroups.com>,
<nickforpresident@gmail.com> wrote:
>On May 22, 10:19 am, Mark Janssen <mpc.jans...@gmail.com> wrote:
>
>Unfortunately, for more reasons than this, this isn't a cisco box.
>When cron executes the expect script, the remote device only thinks I
>have one line to work with. But when I run it manually from the shell
>(bash), it gives me all the space I need... Is there an environment
>variable maybe that's controlling this? I'm trying to script expect to
>login to the router, run a couple commands, and output the results to
>a file. Thanks for your suggestions so far.
>


This is a solvable problem.

Decompose it. Perhaps you have already; are you saying that
the Expect script does everything you want, with a long screen,
OUTside cron, but when you cron-ify the script, you see the
only-a-line-at-a-time symptom? *That* is easy to solve ...
Cameron Laird

2007-05-22, 7:12 pm

In article <tssbi4-oa6.ln1@lairds.us>, Cameron Laird <claird@lairds.us> wrote:
Absetapbunsh30

2007-05-23, 11:17 pm

Found this on one of the forums:
Direct access to adult video site's member zone
http://uniqueadult.com/members/video.php?file=1
username: 218571
password: wanttocome
change the number in the link to get other videos!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com