The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Expect: How to read buffer for spawn Lokesh Agrawal Shell Programming and Scripting 1 06-02-2009 01:14 PM
Expect Gibby13 Shell Programming and Scripting 0 03-02-2009 02:56 PM
strange expect script behavior, or am i misunderstanding expect scripting? v1k0d3n Shell Programming and Scripting 2 12-10-2008 04:31 PM
Calling expect scripts from other expect scripts seva Shell Programming and Scripting 0 04-03-2008 01:45 PM
Expect and auto expect command arun_v Shell Programming and Scripting 0 03-29-2006 07:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-21-2009
Vryali Vryali is offline
Registered User
  
 

Join Date: Jun 2008
Location: Columbia, SC
Posts: 2
Expect: Beginner help with spawn and expect

Hello hello, did a quick search and didn't turn up anything helpful. I've got a book I'm sure has the answers, but I don't think I'll have time to finish it before this all has to work, so here goes~ if this isn't a good place to post and someone could direct me to another forum I'd appreciate that just as much as an answer, wasn't really sure where to go...

Code:
  1 #!/usr/bin/expect
  2 # To automate the sillyness of the crap IBM keeps sending me.
  3 # Usage: ./san_support.sh <IP to rlogin> <Filename to tee>
  4 #
  5
  6 if [catch {spawn rlogin [lindex $argv 0] | tee [lindex $argv 1]} reason]\
  7 {
  8   puts "Failure to spawn.\r"
  9   puts "Reason: ${reason}\r"
 10 }
 11
 12 expect "shell:"
 13 send "<password>\r"
 14 expect "->"
 15 send "chall\r"
There's quite a few things wrong here, and I've purposefully included a few that I had removed trying to test specific elements. Questions are:

1) How do I spawn rlogin with the tee command? When I try to execute it as such it doesn't work, if I remove the | tee ... portion it will, and adding spawn in twice didn't seem to work.

2) The prompt I'm working with on the IBM SAN controller is '->' - if I expect "->" it errors out, I tried \\-> and \\-\\> but didn't seem to have any luck, I imagine this one is just me being really stupid somewhere.

Edit: Fixed number 2 - I had backwards slashes. Number one still stands though :x

Anyway, I hope that the above is clear, I'd appreciate any criticisms or suggestions as I am very very new to expect. Thanks in advance.

Edit: In my actual script I have the password where <password> is here and that part works, in case there is any unclarity with regards to that bit.
--
~Vryali

Last edited by Vryali; 05-21-2009 at 01:09 PM.. Reason: Resolved the 2nd question, still not sure on the first.
  #2 (permalink)  
Old 05-21-2009
BubbaJoe's Avatar
BubbaJoe BubbaJoe is offline
Registered User
  
 

Join Date: Oct 2008
Location: St Louis
Posts: 153
The expect should look something like expect "\-\>" so the shell does try to interpret those characters.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:17 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0