LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I cant able to edit the file from one server to another server. (https://www.linuxquestions.org/questions/linux-newbie-8/i-cant-able-to-edit-the-file-from-one-server-to-another-server-4175456938/)

HariharanV 04-05-2013 04:21 AM

I cant able to edit the file from one server to another server.
 
Hi All,

I am very new for shell script, actually am try to edit the file from master server to client server, but i cant able to edit the client server file. I had use the below command.

ssh -t user@hostename /usr/bin/sudo sh -c 'echo -e "#How long to keep log files (days), maximum is a month\n""#Change no 123456789 dated on 3rd April 2013\n""HISTORY=30" > /etc/sysconfig/sysstat'

Can any one please help me out on this.

Thanks in advance.
Hariharan V.

jpollard 04-05-2013 07:43 AM

It would be easier to use:
Code:

ssh-t user@hostename /usr/bin/sudo sh -c "cat >/etc/sysconfig/sysstat" <<-EOF
    #How long to keep log files (days), maximum is a month
    #Change no 123456789 dated on 3rd April 2013
    HISTORY=30
EOF


The blanks at the beginning of the lines is a "tab" character.

man bash, and look for "here documents"

Hariharan 04-08-2013 07:09 AM

Hi jpollard thanks a lot


All times are GMT -5. The time now is 05:11 PM.