Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 894
  • Last Modified:

CentOS/SSH: append text to file

Hi All,

How do i add text to the bottom of a file using SSH?


Thanks
0
detox1978
Asked:
detox1978
  • 3
  • 2
1 Solution
 
woolmilkporcCommented:
ssh is a secure remote shell and not a text manipulation program.

What exactly is your requirement?

wmp
0
 
detox1978Author Commented:
I want PHP to manage email forwarding.

Currently I connect via SSH and append a line of text to /etc/postfix/virtual using vi

Ideally i'd like to do this via a script online.

0
 
woolmilkporcCommented:
ssh user@host 'echo "my new line of text" >> /etc/postfix/virtual'

wmp
0
 
detox1978Author Commented:
That worked thanks.

When i check the file it has blue "^M" at the end of each line, is this important?
0
 
woolmilkporcCommented:
This is because you obviously transferred the file from Windows to Linux in FTP ASCII mode.
It can cause problems, depending on the application.
I assume Postfix is able to handle it correctly, but better use "BINARY" transfer in the future.
The ^M (carriage return) characters are not related to the method of appending text with "echo" and ">>", however.

wmp
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now