Home > database >  How to download all files in a directory using expect command
How to download all files in a directory using expect command

Time:06-17

I am using the expect command to download some files automatically. But it does not download all the files, it only downloads 16 files out of a total of 41.

This runs automatically and I can't use interact

What am I missing and how do I download the remaining files?

expect.dat

spawn scp -r [email protected]:/data/dcrm_int/ftp/out/20220407/*REP_ACCOUNT_20220407* /process/filesW/.
expect "*?assword*"
send "pps0\r"
expect eof
exit

executing expect file

[12:08:34] data:~/filesW$ expect expect.dat
spawn scp -r [email protected]:/data/dcrm_int/ftp/out/20220407/*REP_ACCOUNT_20220407* /process/filesW/.
Authorized users only. All activity may be monitored and reported.
Password:
DWH_REP_ACCOUNT_20220407_000001.txt.gz           100%   41MB  72.3MB/s   00:00
DWH_REP_ACCOUNT_20220407_000001.vers            100% 3359     5.5MB/s   00:00
DWH_REP_ACCOUNT_20220407_000002.txt.gz           100%   41MB  63.9MB/s   00:00
DWH_REP_ACCOUNT_20220407_000003.txt.gz           100%   41MB  70.8MB/s   00:00
DWH_REP_ACCOUNT_20220407_000004.txt.gz           100%   40MB  65.4MB/s   00:00
DWH_REP_ACCOUNT_20220407_000005.txt.gz           100%   41MB  73.0MB/s   00:00
DWH_REP_ACCOUNT_20220407_000006.txt.gz           100%   41MB  69.9MB/s   00:00
DWH_REP_ACCOUNT_20220407_000007.txt.gz           100%   41MB  72.8MB/s   00:00
DWH_REP_ACCOUNT_20220407_000008.txt.gz           100%   41MB  66.5MB/s   00:00
DWH_REP_ACCOUNT_20220407_000009.txt.gz           100%   41MB  70.3MB/s   00:00
DWH_REP_ACCOUNT_20220407_000010.txt.gz           100%   41MB  63.7MB/s   00:00
DWH_REP_ACCOUNT_20220407_000011.txt.gz           100%   41MB  70.4MB/s   00:00
DWH_REP_ACCOUNT_20220407_000012.txt.gz           100%   41MB  65.9MB/s   00:00
DWH_REP_ACCOUNT_20220407_000013.txt.gz           100%   41MB  72.4MB/s   00:00
DWH_REP_ACCOUNT_20220407_000014.txt.gz           100%   38MB  62.3MB/s   00:00
DWH_REP_ACCOUNT_20220407_000015.txt.gz           100%   36MB  64.7MB/s   00:00
[12:11:14] data:~/filesW$

total files

[12:14:47] data:~/filesW$ ssh [email protected] ls /data/dcrm_int/ftp/out/20220407/*REP_ACCOUNT_20220407* | wc -l
Authorized users only. All activity may be monitored and reported.
Password:
41

CodePudding user response:

expect eof is timing-out. The default timeout value is 10 seconds, so apparently 16 files is how many can be copied in that time.

Solution:

send "pps0\r"
set timeout -1
expect eof
  • Related