Expect Script Strangeness


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Expect Script Strangeness
# 1  
Old 09-02-2008
Expect Script Strangeness

Hi all,

I am trying to use a very simple expect script to automate entering one or two details into a console connection of a solaris machine so that I can do a boot net - install.

If I run the console connection script manually myself, it connects fine and when I hit enter, I am on the machine and can log in etc.

Problem is, when I spawn this exact same command from within expect, the connection seems to work but when I hit enter, nothing

Code:
spawn /console/conn.sh machinename
sleep 15
expect "Connected to"
send ""
expect "telnet>"
send "send break\r\r"
expect "ok"

What might be different about spawn, than running script from the command line.
# 2  
Old 09-02-2008
You don't need double \r\r statement, one carriage return is OK, also, set the timeout to indefinite with : set timeout -1
Your machine may be experiencing slow responses, so rule that out. You can also try autoexpect too that comes with the expect installation.
# 3  
Old 09-03-2008
Sysgate is right on. A couple things I'd do would be too add a debug option to the script...
Code:
if {[lsearch -exact $argv "-debug"] >= 0} {exp_internal 1 ; log_user 1}

..and instead of sending whitespace, send a newline.

HTH
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Expect script returning string following a found expect.

I'm fairly new to scripting so this might not be possible. I am using Expect with Cisco switches and need to capture the string after finding the expect request. For example, when I issue "show version" on a Nexus switch, I'm looking to capture the current firmware version: #show version ... (0 Replies)
Discussion started by: IBGaryA
0 Replies

2. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

3. Solaris

SSH strangeness

Two SPARC servers running latest patches on S10U11. When the mysql account logs into either machine from a windows 7 workstation via putty or other ssh program, the first attempt works fine. Trying to ssh in from the same terminal a second time using either the mysql account or any other LDAP... (5 Replies)
Discussion started by: cjhilinski
5 Replies

4. Programming

Calling another expect script inside an expect script

I have an expect script called remote that I want to call from inside my expect script called sudoers.push, here is the code that is causing me issues: set REMOTE "/root/scripts/remote" ... log_user 1 send_user "Executing remote script as $user...\n" send_user "Command to execute is: $REMOTE... (1 Reply)
Discussion started by: brettski
1 Replies

5. Programming

Calling expect script inside another expect

Hi, Am very new to expect scripting.. Can You please suggest me how to call an expect script inside another expect script.. I tried with spawn /usr/bin/ksh send "expect main.exp\r" expect $root_prompt and spawn /usr/bin/ksh send "main.exp\r" expect $root_prompt Both... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies

6. Shell Programming and Scripting

Need help with Expect script for Cisco IPS Sensors, Expect sleep and quoting

This Expect script provides expect with a list of IP addresses to Cisco IPS sensors and commands to configure Cisco IPS sensors. The user, password, IP addresses, prompt regex, etc. have been anonymized. In general this script will log into the sensors and send commands successfully but there are... (1 Reply)
Discussion started by: genewolfe
1 Replies

7. Shell Programming and Scripting

strange expect script behavior, or am i misunderstanding expect scripting?

Hello to all...this is my first post (so please go easy). :) I feel pretty solid at expect scripting, but I'm running into an issue that I'm not able to wrap my head around. I wrote a script that is a little advanced for logging into a remote Linux machine and changing text in a file using sed.... (2 Replies)
Discussion started by: v1k0d3n
2 Replies

8. Solaris

Cron strangeness

Good Morning Fellow Admins! I have a v880 running Sol9. The cron daemon is executing a crontab for a user and the user is in /etc/cron.d/cron.deny. /etc/cron.d/cron.allow exists and the user is not in it. What am I missing? Thanks in Advance! Tony (3 Replies)
Discussion started by: bluescreen
3 Replies

9. IP Networking

IP# Strangeness Please Help

Hi I've stumbled over something that caught my attention but I'm not familiar enough with IPs to know if this is suspect or irrelevant. If you'd take the time to read and respond I'd greatly appreciate it. I'm just stumped. I've done a site for some people (4 in the group) awhile ago and set... (4 Replies)
Discussion started by: jolene
4 Replies
Login or Register to Ask a Question