LoginSignup
1
0

サーバ間でのデータ転送をUGEで実行する

Posted at

サーバAから遺伝研スパコンへ、UGEで大量にsftpでファイルを転送したい場合のジョブスクリプト(備忘録)。

$ cat transfer.sh
#!/bin/sh
#$ -cwd

sshpass -p 'yourpassword' sftp -oPort=xxxx -oCiphers=aes256-cbc -oBatchMode=no -b - username@server.address.com << !
#   sftpのコマンドが使用できる
#   cd remote_directory_path
#   lcd local_directory_path
   mget *
   bye
!

sftpのオプション
username@server.address.com: サーバAのアカウント名とアドレス
yourpassword: サーバAのパスワード
-oPort=xxxx: サーバAにポート指定がある場合
-oCiphers=aes256-cbc: サーバAに暗号化方式の指定がある場合

最後の!は、勝手にテキストエディタがスペースを補完することがあり、そのままだとエラーになるので注意する。例えばこのスクリプトを実行すると、

sshpass -p 'yourpassword' sftp -oPort=xxxx -oCiphers=aes256-cbc -oBatchMode=no -b - username@serveradress << !
#   cd remote_directory_path
#   lcd local_directory_path
   mget *
   bye
     !

以下のエラーが出る。

transfer.sh: line 10: warning: here-document at line 5 delimited by end-of-file (wanted `!')
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0