とらりもんHOME  Index  Search  Changes  Login

G-Portal

mass downloading using a script

Install "expect" in your computer (just one time):

$ sudo apt install expect

Writing a script. note that ****** is username and ###### is a password.

$ vi KuPR_download.ext 
#!/usr/bin/expect -f
set timeout -1
spawn sftp -P 2051 ******@ftp.gportal.jaxa.jp
expect "password:"
send "######\r"
expect "sftp>"
send "mget /standard/GPM/GPM.DPR/2A.Ku/07A/2023/??/??/*.h5\r"
expect "sftp>"
send "mget /standard/GPM/GPM.DPR/2A.Ku/07A/2022/??/??/*.h5\r"
expect "sftp>"
send "exit\r"
$ chmod +x KuPR_download.ext

Run it:

$ ./KuPR_download.ext

In case you want to do it in a background process on a server:

$ nohup ./KuPR_download.ext > /dev/null 2>&1 &
Last modified:2023/09/16 10:31:35
Keyword(s):
References: