Expect issue??


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Expect issue??
# 1  
Old 02-13-2009
Expect issue??

I have these variables set:

FTPPATH=/directory/test/customer
FTPFILE=file.txt


I am trying to call this function:

ftpFiles () {

echo ${FTPPATH} ${FTPFILE} | expect >/dev/null <<EOF
set ftppath [lindex $argv0]
set ftpfile [lindex $argv1]
spawn sftp xxxxxx@server1
expect "password:"
send "xxxxxxxx\r"
expect "sftp> "
set timeout 800
send "cd $ftppath\r"
expect "sftp> "
send "get $ftpfile\r"
expect "sftp> "
send "bye\r"
EOF

}

when i call it i get this issue

Wrong args # should be "lindex list index"
while executing "lindex script"
invoked from within
set ftppath [ lindex script ]


I don't think the variables are being read any help????
# 2  
Old 02-13-2009
You should try the autoexpect. It works great. It will create the script for you. Once you have it, you can compare and see what's missing. That's what I did for my SFTP issue.
# 3  
Old 02-13-2009
Quote:
Originally Posted by Pablo_beezo
I have these variables set:

FTPPATH=/directory/test/customer
FTPFILE=file.txt


I am trying to call this function:

ftpFiles () {

echo ${FTPPATH} ${FTPFILE} | expect >/dev/null <<EOF
set ftppath [lindex $argv0]
set ftpfile [lindex $argv1]
spawn sftp xxxxxx@server1
expect "password:"
send "xxxxxxxx\r"
expect "sftp> "
set timeout 800
send "cd $ftppath\r"
expect "sftp> "
send "get $ftpfile\r"
expect "sftp> "
send "bye\r"
EOF

}

when i call it i get this issue

Wrong args # should be "lindex list index"
while executing "lindex script"
invoked from within
set ftppath [ lindex script ]


I don't think the variables are being read any help????
First, use code tags.
Second, it is
Code:
 lindex $argv 0

not
Code:
lindex $argv0

Third, that's an ugly function. Would be cleaner to just make an expect script.
Fourth, why not use scp and keys?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Issue in installing expect and Tcl

Hi I need to install expect in redhat. through net I came to know that I must install tcl too in order to make expect work. I have downloaded both packages but not able to install # ls -lrt total 3720 18:33 tcl8.4.20-src.tar.gz 18:33 expect5.45.3.tar.gz 18:40 expect5.45.3... (7 Replies)
Discussion started by: scriptor
7 Replies

2. Shell Programming and Scripting

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## cat bscfile.txt | while read line do NODE=$line ./expect.sh $line $NAME done line= 1st input NAME=2nd input... (1 Reply)
Discussion started by: yadvinder_singh
1 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

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

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

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

8. AIX

Performance issue in expect library on AIX 5.3

Hi All, I am getting a performance issue in expect5.43.0 library on IBM AIX 5.3. When I have used exp_fexpectv call for pattern matching with the expect string, the execution latency of the call is approximately 200 ms. In that way, I am able to complete only 4 or 5 transactions per... (2 Replies)
Discussion started by: ravindra_maddal
2 Replies

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

10. Shell Programming and Scripting

expect issue...help!

Could anyone tell me any reason why the following does not work, please: \#!/usr/local/bin/expect -f set PASSWORD "xxxxxxx" print "spawn sftp $user@rnode" print "expect \"password:\r\"" print "send \"$PASSWORD\r\" ... expect eof It this expect script is embedded into a ksh script, but... (1 Reply)
Discussion started by: nimrodman
1 Replies
Login or Register to Ask a Question