Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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)

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted
  • 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:salty@ftp.website.com/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.

share|improve this answer
add comment

Another useful and secure command you can use would be the scp command which uses ssh to copy files to and fro.

To use this you can use seahorse to create an ssh key pair and copy the public part of the key to ~/.ssh/. You should not protect the password you use for this with a password since you don't want to login to use it. You should probably only use the password pair you use for this for this script. You use the scp -i identity option to select it.

The private key takes the place of a plaintext password.

I assume you could place an invocation of the script in your crontab if desired.

With izx's helpful approach you need to be careful to protect where you place the script to protect the password "salty" for the remote computer from prying eyes. With this approach you'll have to take the same care to protect the private part of the key pair since it is not password protected.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.