I'm writing a new backup script in [Powershell][1] to backup our [Azure SQL][2].

After the backup, I need to write into a logfile on a remote linux server.

I thought about using plink (the [putty][3] command line tool). More or less like this:

plink user@server /var/log/logfile<"TEXT"

However, most of you will remark that this isn't possible, and I also learned this :)

Is there no easy way to add a line of text to an existing file on a remote linux system using plink?


One pretty common method is to use tee. Try one of these.

echo "TEXT" | plink.exe user@server tee /var/log/logfile

type localfile.txt | plink.exe user@server tee /var/log/logfile
  • Thx! Actually I should have known this command but I've never used it before. I did only one small change to make it append the text and not overwrite it everytime: echo "TEXT" | plink.exe user@server tee -a /var/log/logfile – platzhersh Mar 6 '12 at 7:19

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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