LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-20-2010, 08:53 AM   #1
danndp
Member
 
Registered: Nov 2010
Posts: 51

Rep: Reputation: 2
How to change a line in a file and send to a remote machine with rsync


Hello my friends,

I'm configuring an rsync between 2 machines, A_Server --> B_Server, using the following script:

Quote:
#!/bin/bash
#
# Script de backup a través de Rsync desde RMP-1 hasta RMP-2.
#
# Si se produce algún error en cualquier momento abortar.
#set -e

DATOS="/tmp/prueba.txt"
EXCLUDES=
OPTS="-vv --relative --delete --force --ignore-errors --delete-excluded --exclude-from=$EXCLUDES -a"
RSERVER="rsync://A_Server@192.168.1.4/A_Server/"
export RSYNC_PASSWORD=1234

#Este script sincroniza los datos de Asterisk de RMP-1 a RMP-2 a través
#del servicio rsyncd. Los datos se guardan en RMP-2 en la carpeta
#/home/RMP-1/.
"
echo
echo "Copiando datos ..."
echo "rsync $OPTS $DATOS $RSERVER"
rsync $OPTS $DATOS $RSERVER
echo "OK"

echo
echo "Hora Fin: $(date)"
echo "=)"
The Rsyn is working OK. What i need is to change one of the lines of the /tmp/prueba.txt before sending it to the remote machine (obviously not changing the file in the local machine), i mean, send prueba.txt to the remote machine deleting one line and adding another one...how can i do this????

sed is a good choice, but no clue how to put all together in the same script...i would appreciate your help

BEST REGARDS!!!
 
Old 11-20-2010, 09:16 AM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
You can change it in the remote server after rsyncing:
Code:
ssh user@B sed -i '23c\'"new line" /path/to/prueba.txt
-i to inline edit
23 is line number
c stand for change
 
Old 11-20-2010, 12:28 PM   #3
danndp
Member
 
Registered: Nov 2010
Posts: 51

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by quanta View Post
You can change it in the remote server after rsyncing:
Code:
ssh user@B sed -i '23c\'"new line" /path/to/prueba.txt
-i to inline edit
23 is line number
c stand for change
Thanks my friend....but i'm trying and is not working

Quote:
<RMP-Sangoma> root@srv-RMP3:~# ssh ddias@192.168.10.3 sed -i '2c\'"new line" /tmp/prueba.txt
ddias@192.168.10.3's password:
sed: no se puede leer line: No existe el fichero o el directorio
sed: cannot rename /tmp//sedCBV2jO: Operación no permitida
Am i missing something?
 
Old 11-20-2010, 12:33 PM   #4
danndp
Member
 
Registered: Nov 2010
Posts: 51

Original Poster
Rep: Reputation: 2
Seems to be a problem of permissology, right?
 
Old 11-20-2010, 12:34 PM   #5
danndp
Member
 
Registered: Nov 2010
Posts: 51

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by danndp View Post
Seems to be a problem of permissology, right?
Sorry...not permissology...."Permitting"....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change a line in a rsync script and send the file changed danndp Linux - Newbie 1 11-20-2010 10:26 AM
rsync not deleting folders on remote machine alexandersv Linux - Software 2 09-03-2008 11:15 AM
Complicated one: MySQL, rsync, remote machine, local machine daiver Linux - General 2 02-27-2006 01:14 PM
rsync Syntax Question for Connecting to Remote Windows Machine Linux31 Linux - Networking 3 10-09-2005 03:55 PM
send message to remote machine AcerKev Linux - Networking 6 02-13-2004 12:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration