2

I'm writing a new backup script in PowerShell to back up our Azure SQL.

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

I thought about using plink (the PuTTY 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?

1 Answers1

1

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

To append the data to the end of the file then use tee -a:

echo "TEXT"        | plink.exe user@server tee -a /var/log/logfile
 
type localfile.txt | plink.exe user@server tee -a /var/log/logfile
Zoredache
  • 20,438