user3658319
user3658319

Reputation: 31

output from expect is not complete

I have this script in order to make rsync with another server, the propossal is to get arround 1600 files, this script as two variables, date and hour, so, I send these two values with shell script then I pass the values.

Expect script:

#!/usr/bin/expect

set DIR_DATE [lrange $argv 0 0]
# Define date variable.

set DT_HOUR [lrange $argv 1 1]
# Define hour variable.

spawn rsync -avzb -e ssh user@IPSERVER:/SOURCE_DIR/$DIR_DATE/A$DIR_DATE.$DT_HOUR*.txt /TARGET_DIR/$DIR_DATE/
expect "password:"
send "PASSWORD\r"
#interact
expect eof

And the shell script is:

#!/bin/bash

***HERE is the code to get date and hour variable: DT_DATE,DT_HOUR; then, next step is run the expect script***

${DIR_BIN}/rsync_expect.sh ${DT_DATE} ${DT_HOUR}

You can note, in the expect script, I comment "interactive" word, because:

  1. If it is not comment and run manually the script, it runs very well, it get 1600 files.
  2. If it is commented, and run through the shell script, it only get arround 50 files and that's off.

So, any sugestion in order to get all files using shell scripts?

Upvotes: 0

Views: 1068

Answers (1)

glenn jackman
glenn jackman

Reputation: 247102

You're probably timing out: 50 files is probably what you can transfer in (default) 10 seconds. Add this before you spawn: set timeout -1

".sh" is a bad file extension for an expect script: use ".exp"

The lrange command returns a list. Use lassign $argv DIR_DATE DT_HOUR

Upvotes: 1

Related Questions