Re: In-Line file edit over SSH with ksh and perl script



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...
.



Relevant Pages

  • Re: In-Line file edit over SSH with ksh and perl script
    ... debugging and you lose the ability to track changes. ... A way is to write a script to do whatever you want (including doing a ... better switch to a real versioning system) and use that. ... # if the script is on the remote machine ...
    (comp.unix.shell)
  • Re: programm auf entferntem PC starten
    ... Remote WSH, which is a new technology included in WSH 5.6, provides the ability to run a script on a remote machine or machines. ...
    (microsoft.public.de.german.scripting.wsh)
  • Re: The algorithm (Re: bash script request)
    ... > sizes in bytes b) the ability to collect these variables from the du -b ... Your problem is not writing a script ... When you have the algorithm you have in mind sorted out ... sizes in m dvds, where m is as small as possible. ...
    (alt.os.linux)
  • Re: Applescript version of macro in Word
    ... It sets Page Layout view, sets Zoom to Page Width, and turns on Track Changes, and turns on the Reviewing toolbar. ... I'm finding that Highlight Changes happens automatically, without script intervention, but holler if you don't find it so. ... set page fit of zoom of view of active window to page fit best fit ...
    (microsoft.public.mac.office.word)
  • Re: script request
    ... the ability to collect these variables from the du -b command in a dir ... these dirs to create the closest of <= $size_of_a_dvd. ... Someone stated the algorithm is impossible with common maths. ... FACT in need of guidance to learn NOT to get a script ready. ...
    (comp.unix.shell)