Guest User

Untitled

a guest
Feb 21st, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. #!/bin/bash
  2. PROTOCOL="ftp"
  3. URL="server.example.com"
  4. LOCALDIR="/home/user/downloads"
  5. REMOTEDIR="dir/remote/server/"
  6. USER="user"
  7. PASS="password"
  8. REGEX="*.txt"
  9. LOG="/home/user/script.log"
  10.  
  11. cd $LOCALDIR
  12. if [ $? -dt 0 ]; then
  13. echo "$(date "+%d/%m/%Y-%T") Cant cd to $LOCALDIR. Please make sure this local directory is valid" >> $LOG
  14. fi
  15.  
  16. lftp $PROTOCOL://$URL <<- DOWNLOAD
  17. user $USER "$PASS"
  18. cd $REMOTEDIR
  19. mget -E $REGEX
  20. DOWNLOAD
  21.  
  22. if [ $? -dt 0 ]; then
  23. echo "$(date "+%d/%m/%Y-%T") Cant download files. Make sure the credentials and server information are correct" >> $LOG
  24. fi
  25.  
  26. 45,30,15,00 * * * * /home/user/downloader.sh >/dev/null 2>&1
  27.  
  28. */15 * * * * /home/user/downloader.sh >/dev/null 2>&1
  29.  
  30. if [ $? -dt 0 ]; then
  31. fi
  32.  
  33. lftp $PROTOCOL://$URL <<- DOWNLOAD
  34. DOWNLOAD
  35.  
  36. user $USER "$PASS"
  37. cd $REMOTEDIR
  38. mget -E $REGEX
  39.  
  40. [root@host ~]# lftp
  41. lftp :~> ?
  42. !<shell-command> (commands) alias [<name> [<value>]]
  43. attach [PID] bookmark [SUBCMD] cache [SUBCMD]
  44. cat [-b] <files> cd <rdir> chmod [OPTS] mode file...
  45. close [-a] [re]cls [opts] [path/][pattern] debug [<level>|off] [-o <file>]
  46. du [options] <dirs> exit [<code>|bg] get [OPTS] <rfile> [-o <lfile>]
  47. glob [OPTS] <cmd> <args> help [<cmd>] history -w file|-r file|-c|-l [cnt]
  48. jobs [-v] [<job_no...>] kill all|<job_no> lcd <ldir>
  49. lftp [OPTS] <site> ln [-s] <file1> <file2> ls [<args>]
  50. mget [OPTS] <files> mirror [OPTS] [remote [local]] mkdir [-p] <dirs>
  51. module name [args] more <files> mput [OPTS] <files>
  52. mrm <files> mv <file1> <file2> [re]nlist [<args>]
  53. open [OPTS] <site> pget [OPTS] <rfile> [-o <lfile>] put [OPTS] <lfile> [-o <rfile>]
  54. pwd [-p] queue [OPTS] [<cmd>] quote <cmd>
  55. repeat [OPTS] [delay] [command] rm [-r] [-f] <files> rmdir [-f] <dirs>
  56. scache [<session_no>] set [OPT] [<var> [<val>]] site <site-cmd>
  57. source <file> torrent [-O <dir>] <file|URL>... user <user|URL> [<pass>]
  58. wait [<jobno>] zcat <files> zmore <files>
  59.  
  60. lftp :~> ? mget
  61. Usage: mget [OPTS] <files>
  62. Gets selected files with expanded wildcards
  63. -c continue, resume transfer
  64. -d create directories the same as in file names and get the
  65. files into them instead of current directory
  66. -E delete remote files after successful transfer
  67. -a use ascii mode (binary is the default)
  68. -O <base> specifies base directory or URL where files should be placed
Add Comment
Please, Sign In to add comment