Need help running expect script under CYGWIN...

View: New views
8 Messages — Rating Filter:   Alert me  

Need help running expect script under CYGWIN...

by cledford :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, much thanks in advance for any and all help anyone can provide.  

I'm by no means a scripting/*NIX/Expect guru - but a while back was able to stumble  through setting up Windows/CYGWIN/expect enough to put together a really functional system for basic network management of Cisco routers and switches.  Everything ran fine on my old laptop which died recently.  I've just downloaded the latest CYGWIN to my new laptop (I'm assuming a newer version since last July) and none of my scripts will work any longer.  They are very basic - essentially they just spawn telnet to a host and do what's in the script.  It appears that with the current version of CYGWIN (or the expect that runs in it) the spawn sessions are dying early.  I've scoured the internet for help, but while there are several people in my same boat - I'm not finding any solutions.  Attached below is my error message, my expect script, and my (simple) shell script that pipes in a list of names/IPs as arguments to expect.

I really relied on this to manage a large number of switches in the past and am really hurting not having this - thanks for any input at all.

-Calvin

ERROR:
=================================

Spawn telnet pn-abrams-switch
Send: invalid spawn id (4)

EXPECT SCRIPT:
=================================

set timeout 20
set USER_NAME "XXXXX"
set USER_PASS "XXXXXX"
set ENABLE_PASS "XXXXXX"
set ROUTER $argv
spawn telnet $ROUTER
expect "Username: "
send "$USER_NAME\r"
expect "Password: "
send "$USER_PASS\r"
expect "#$"
send "term length 0\r"
expect "#$"
log_file ./output/$ROUTER-show_run.txt
send "sh run | include hostname\r"
expect "#$"
send "\r"
expect "#$"
send "\r"
expect "#$"
send "sh run"
expect "#$"
send "\r"
expect "#$"
log_file
send "exit\r"

SHELL SCRIPT:
===================================

for ROUTER in `cat names.txt`; do ./expect-BABW-show_run.txt $ROUTER; done

Re: Need help running expect script under CYGWIN...

by Brian Dessent :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

cledford wrote:

> I'm by no means a scripting/*NIX/Expect guru - but a while back was able to
> stumble  through setting up Windows/CYGWIN/expect enough to put together a
> really functional system for basic network management of Cisco routers and
> switches.  Everything ran fine on my old laptop which died recently.  I've
> just downloaded the latest CYGWIN to my new laptop (I'm assuming a newer

You didn't mention whether you were using Windows' telnet.exe or
Cygwin's (inetutils) telnet.  (If you had attached the cygcheck output
as per the reporting guidelines this would have been clear.)  You
probably will have difficulty using Windows' telnet with expect as it
does not know about ptys, but Cygwin's telnet should work fine.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Re: Need help running expect script under CYGWIN...

by cledford :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Brian - thanks for the reply.  I am using the windows telnet (not by choice) as I could not find a native CYGWIN telnet app in /usr/bin.  Would you happen to know what "catagory" the telnet app is and I'll go back to the CYGWIN website and download?

Here is the output of the cygcheck -c (not sure which option to run - will go back and look for instructions...)

Anyhow, thanks for the heads up.

-Calvin

Cygwin Package Information
Package              Version            Status
_update-info-dir     00347-1            OK
alternatives         1.3.20a-2          OK
ash                  20040127-3         OK
base-files           3.6-1              OK
base-passwd          2.2-1              OK
bash                 3.0-14             OK
bzip2                1.0.3-1            OK
cabextract           1.1-1              OK
coreutils            5.93-2             OK
cygutils             1.2.9-1            OK
cygwin               1.5.19-3           OK
cygwin-doc           1.4-3              OK
diffutils            2.8.7-1            OK
editrights           1.01-1             OK
expect               20030128-1         OK
findutils            4.2.27-1           OK
gawk                 3.1.5-2            OK
gdbm                 1.8.3-7            OK
grep                 2.5.1a-2           OK
groff                1.18.1-2           OK
gzip                 1.3.5-1            OK
less                 381-1              OK
libbz2_1             1.0.3-1            OK
libcharset1          1.9.2-2            OK
libgdbm              1.8.0-5            OK
libgdbm-devel        1.8.3-7            OK
libgdbm3             1.8.3-3            OK
libgdbm4             1.8.3-7            OK
libiconv             1.9.2-2            OK
libiconv2            1.9.2-2            OK
libintl              0.10.38-3          OK
libintl1             0.10.40-1          OK
libintl2             0.12.1-3           OK
libintl3             0.14.5-1           OK
libncurses5          5.2-1              OK
libncurses6          5.2-8              OK
libncurses7          5.3-4              OK
libncurses8          5.4-4              OK
libpcre0             6.3-1              OK
libpopt0             1.6.4-4            OK
libreadline4         4.1-2              OK
libreadline5         4.3-5              OK
libreadline6         5.0-4              OK
login                1.9-7              OK
man                  1.5p-1             OK
mktemp               1.5-3              OK
ncurses              5.4-4              OK
run                  1.1.6-1            OK
sed                  4.1.4-1            OK
sharutils            4.5.3-1            OK
tar                  1.15.1-3           OK
tcltk                20030901-1         OK
termcap              20050421-1         OK
terminfo             5.4_20041009-1     OK
texinfo              4.8-1              OK
unzip                5.50-5             OK
which                1.7-1              OK
zip                  2.3-6              OK
zlib                 1.2.3-1            OK

Re: Need help running expect script under CYGWIN...

by Brian Dessent :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

cledford wrote:

> Hi Brian - thanks for the reply.  I am using the windows telnet (not by
> choice) as I could not find a native CYGWIN telnet app in /usr/bin.  Would
> you happen to know what "catagory" the telnet app is and I'll go back to the
> CYGWIN website and download?

As I already said in my previous reply, you want the inetutils package.
And you can always use the package search page on the website.

> Here is the output of the cygcheck -c (not sure which option to run - will
> go back and look for instructions...)

Arrrrggh.  When you put this inline you just frustrate people trying to
search the mailing list archives because the entire contents will be
indexed and cause keyword searches for unrelated subjects to match.
This is why the instructions ask you to send it as an attachment.  But
of course you can't attachments because...

> Sent from the Cygwin Users forum at Nabble.com.

...you're using /this/.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Re: Need help running expect script under CYGWIN...

by cledford :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry to all for skewing the index - in the future is should be made much more obvious the requirements/process to post a technical question. (I posted through the web interface and instructions would be nice)

For anyone running into this issue - the problem was the default use (by CYGWIN) of the windows telnet app.  By downloading and installing the suggested / inetutils package (located in the - net category under the package installer) CYGWIN then uses its own telnet app instead.

-Calvin

Re: Need help running expect script under CYGWIN...

by Igor Peshansky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 30 Jun 2006, cledford wrote:

> Sorry to all for skewing the index - in the future is should be made
> much more obvious the requirements/process to post a technical question.
> (I posted through the web interface and instructions would be nice)

The instructions are at <http://cygwin.com/problems.html> (just a short
click away from the Cygwin home page, with the link named "Problem
Reports" -- I don't know how much more obvious you can get).  You posted
through the web interface at Nabble (which is not associated with Cygwin).
You might want to do some lobbying for them to include a link to the above
instructions.  And while you're at it, please tell them to allow posting
attachments using their web interface.

> For anyone running into this issue - the problem was the default use (by
> CYGWIN) of the windows telnet app.  By downloading and installing the
> suggested / inetutils package (located in the - net category under the
> package installer) CYGWIN then uses its own telnet app instead.

The default use is of whatever telnet app is in the PATH first.  That is
not a problem -- that is expected behavior.  The problem was that you were
missing the inetutils package, as Brian pointed out.  You could've
searched for "bin/telnet\b" on the package search page at
<http://cygwin.com/packages/>, or via "cygcheck -p", to get this
information yourself.
        Igor
--
                                http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_    pechtcha@... | igor@...
ZZZzz /,`.-'`'    -.  ;-;;,_ Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-' old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Re: Need help running expect script under CYGWIN...

by fschmidt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Igor Peshansky-2 wrote:
You posted
through the web interface at Nabble (which is not associated with Cygwin).
You might want to do some lobbying for them to include a link to the above
instructions.
No lobbying required.  Nabble has a wiki-like system so anyone can change forum description.

And while you're at it, please tell them to allow posting
attachments using their web interface.
Coming soon, in a few weeks.

Franklin Schmidt
Nabble.com

Re: Need help running expect script under CYGWIN...

by Christopher Faylor-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Jun 30, 2006 at 04:17:31PM -0700, fschmidt wrote:
>Igor Peshansky-2 wrote:
>>You posted through the web interface at Nabble (which is not associated
>>with Cygwin).  You might want to do some lobbying for them to include a
>>link to the above instructions.
>
>No lobbying required.  Nabble has a wiki-like system so anyone can
>change forum description.

But those of us who do not use nabble but do try to maintain up-to-date
instructions on the web sites that we manage are not particularly
interested in getting sucked into maintaining descriptions at two
separate sites.

There is a catch-22 here, I guess.  If Nabble really catches on, it
might be necessary to start blocking them just to cut down on people
sending email without understanding the rules.

cgf

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

LightInTheBox - Buy quality products at wholesale price!