expect script issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting expect script issue
# 1  
Old 06-01-2012
expect script issue

Hi All,

I have the problem to run the commands in expect script from shell script.

Mentioned below is the shell and expect script.

##Shell Script##

Code:
cat bscfile.txt | while read line 
do 
          NODE=$line 
         ./expect.sh $line $NAME
done

line= 1st input
NAME=2nd input

##expect script##
Code:
#!/usr/local/bin/expect -f 
#set -x
set NODENAME [lindex $argv 0]   
set NAME [lindex $argv 1] 
set timeout 50 
spawn eaw "$NODENAME\r" 
expect "<"   
sleep 01 
send "xxx:xxx=xxx,xxx=$NAME;\r"    # here it automatically gets the name.
expect "<"
sleep 00 
send "exit;\r"

By using the above script

I am able to login using node name(which is basically the BSC Node).Also
my first command is working fine.

Input of nodename and cellname i am getting from shell script and is automatically taking that values of NODENAME and NAME


But for me the next challenge is to run the next commands ..


In above expect script we have


send "xxx:xxx=xxx,xxx=$NAME;\r"

and output of this command is:


Mentioned output is

G=1

so my next command should take these values of G1 which is 1

by fetching that selected value "1" automatically and put that value 1 in the space provided in the below mentioned command

<xxx:xx=xxx- ; # By defining "1" in the space command should run


After this it finally exit.


How can i do that. How should i define the variables for the next commands also?


..I am totally stuck..


Somebody help me in this ASAP....

Thanks
in advance !!!

Last edited by yadvinder_singh; 06-01-2012 at 06:05 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 06-01-2012
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.
This User Gave Thanks to Franklin52 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Expect scripting issue, works interactively when doing commands in cli, does not work in script

Hi; problem may be obvious, simple but I have to say it is somehow not easy to locate the issue. I am doing some word extracting from multiline text. Interacting in CLI seems to work without issues. First step is to add multiline text to a variable. expect1.1> expect1.1> set... (2 Replies)
Discussion started by: aldowski
2 Replies

2. 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

3. Shell Programming and Scripting

expect ssh script issue with if and foreach

Hi, I am trying to create an ssh script to login to cisco routers and activate/deactivate bgp neighbors if they match certain conditions. I dont think my "if" and "foreach" are working correctly. Any help is appreciated. Below is my script: ... (0 Replies)
Discussion started by: blahblahsomeone
0 Replies

4. Shell Programming and Scripting

help to handle the expect script issue

Hi experts I know the expect script can match the terminal output to run the the following cmd I write a script with expect named "test", I want to run ten "test" with background running, for ((i=1;i<=10;i++) do ./test -n $i done I find all the output of test will print on one... (0 Replies)
Discussion started by: yanglei_fage
0 Replies

5. 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

6. Shell Programming and Scripting

Issue - Expect Script.

Hi Gurus,I am trying to automate SFTP using expect.I have written a script that logs into a few boxes(one after the other) and pulls a few files from them.The code:#!/bin/kshcat serverlist.conf|wc -l >> tmp #serverlist.conf contains the list of servers.tmp1=$tmpfor tmp1 in listdo while read... (3 Replies)
Discussion started by: Hari_Ganesh
3 Replies

7. Solaris

Issue with Expect Script for SFTP.

Hi Experts, I am learning expect and wrote the below script for automatic sftp into a server: #!/usr/local/bin/expect -f -d spawn sftp -v test@mumux503 # logs into mumux503 as test user expect "password:" sleep 20 send "test\r"; # sending the password for test... (3 Replies)
Discussion started by: Hari_Ganesh
3 Replies

8. Shell Programming and Scripting

Expect script issue

This is my expect script . set USERNAME set PASSWD set IP set timeout 15 spawn telnet $IP expect "login:" send "$USERNAME\r" expect "Password:" send "$PASSWD\r" expect "Password:" send "$PASSWD\r" expect "*\>" send "show version\r" expect "*\>" send "quit\r" ouput of it (0 Replies)
Discussion started by: robbiezr
0 Replies

9. 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

10. Shell Programming and Scripting

Expect script issue

HI Al, I have written the following expect script: #!/bin/ksh #!/usr/local/bin/expect-- ##echo "PLease enter the server name" ##read host echo "please enter the instance" read instance set ##password to be entered right before the script is run## ##/usr/local/bin/expect<<-EOF cat... (2 Replies)
Discussion started by: Segwar
2 Replies
Login or Register to Ask a Question