Re: In-Line file edit over SSH with ksh and perl script
- From: inetquestion <inetquestion@xxxxxxxxxxx>
- Date: Sun, 19 Jul 2009 18:13:27 -0700 (PDT)
On Jul 19, 1:40 pm, pk <p...@xxxxxxxxxx> wrote:
inetquestion wrote:
question lies. Before I would do something like below and life was
good.
ssh $SERVER "perl-e 's/old-suff/new-stuff/' $FILE"
I don't think so. The above line has many errors.
The problem I've run into is this doesn't provide much room for
debugging and you lose the ability to track changes. Furthermore it
seems you need to escape more characters then the example solution
(below) I started writing last night. While this particular example
is admittedly simple and could be done in many other ways, I do have
more complex situations in mind to deal with such as making 50 or so
changes to one file with much more complex regex patterns. I am
curious to see what others have done in this area and what suggestions
others may have to deal with this or a similar problem.
A way is to write a script to do whatever you want (including doing a
versioned backup of the file, though for moderately complex tasks you
better switch to a real versioning system) and use that. For example:
# if the script is on the remote machine
ssh "$SERVER" /remote/path/to/yourscript.sh
# if the script is on the local machine
ssh "$SERVER" < /local/path/to/yourscript.sh
Incorrect: ssh $SERVER "perl-e 's/old-suff/new-stuff/' $FILE"
Corrected: ssh $SERVER "perl -pi.bak -e 's/bash/ksh/' $FILE"
Nonetheless, the corrected sample is lacking in many areas, namely
auditing, ability to catch errors for logging or applying logic
decisions...etc...
.
- References:
- In-Line file edit over SSH with ksh and perl script
- From: inetquestion
- Re: In-Line file edit over SSH with ksh and perl script
- From: pk
- In-Line file edit over SSH with ksh and perl script
- Prev by Date: Re: How do you make this Open Source work on Solaris 10?
- Next by Date: Re: UTF-8 characters randomly displayed in xterm
- Previous by thread: Re: In-Line file edit over SSH with ksh and perl script
- Next by thread: rsync error logging
- Index(es):
Relevant Pages
|