Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  12] [ 0]  / answers: 1 / hits: 32061  / 2 Years ago, sat, january 8, 2022, 5:10:14

I need to take make a script that takes a particular log file in /var/log/ and puts it somewhere where I can easily get it (most likely a web or FTP server I have access to). I don't think I want to use mail to send it. Webdav might be an option. It just needs to work without any user interaction, and be pretty fast and painless. Any suggestions? (no password needed, basically)


More From » scripts

 Answers
2

  • Log files in /var/log are usually world-readable and require no password to access.

  • If you already have an FTP server -- could be a back-end to a web-server too -- the simplest option IMO is to use the wput utility.

    • Install it with sudo apt-get install wput if necessary.

    • The syntax is:
      wput [options] [file]... [url]...

    • where the URL is of the form:
      ftp://[username[:password]@]hostname[:port][/[path/][file]]


  • Example:




    wput /var/log/syslog ftp://jack:[email protected]/www/mylogs/

  • Use the -u option to force an upload when the destination file already exists.


  • See wput --help or man wput for many more options.




Note: Putting the password in plaintext as in the examples above is extremely insecure in general; I strongly recommend creating a restricted FTP account on the server which only allows uploads to a special directory you create for downloading/viewing the logs.



[#36260] Sunday, January 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ingwhin

Total Points: 332
Total Questions: 112
Total Answers: 115

Location: Burkina Faso
Member since Tue, Apr 26, 2022
2 Years ago
;