SSH Find and Replace

Amit,

NOTE that anything you do while logged in through ssh can completely destroy your entire system. BE CAREFUL.

What you're really trying to do is quite simple, but the problem is you have no frame of reference from which to try any of the suggestions given.

So here's my attempt to give you a frame of reference...

You use ssh the same way you use the DOS shell under Windows, the difference being that you use ssh across the net.

So the first thing to do is to log into your server, using ssh, and a login that gives you enough rights to change the files you need to change.

Unless all the files are owned by the same user that will have to be root.

Once you're logged in either as root, or as the user that owns all the files you now have to identify the files.

Do you know where all these files are located? Do you know where they are?

Can you create a path, using wildcards, that will help you identify all the files?

For example, while logged in as root, would /home/*/domains/*/public_html/*.html be a good wildcard that will identify all the files?

Are all the changes to be made from one specific path to another specific path?

If so you can use some of the ideas given.

If not, you'll have to start explaining the differences between what I've written and your actual environment.

Jeff
 
okay lets try replying back
-----------------------------------
NOTE that anything you do while logged in through ssh can completely destroy your entire system. BE CAREFUL.

True! am following the pattern just as its given to me. and hence asking for guidance on every step if am unsure.
-------------------------------------------------
You use ssh the same way you use the DOS shell under Windows, the difference being that you use ssh across the net.

Very True.
-------------------
So the first thing to do is to log into your server, using ssh, and a login that gives you enough rights to change the files you need to change.
Unless all the files are owned by the same user that will have to be root.

I have the rights, i have the root username and password
-----------------------------------------

yes i do have the path, it goes something like
/home/username/domains/domainname.com/public_html
----------------------------------------------------------
For example, while logged in as root, would /home/*/domains/*/public_html/*.html be a good wildcard that will identify all the files?

not really sure what u mean on this
----------------------------------------------------------

what's the command for executing a certain file (.pl) on the server?

Best Regards
Amit
 
Perl is an interpreted language, which is why you must specify the path to perl (the interpreter).

Since you said that perl was located at /usr/local/bin/perl
you will need to modify the shebang line at the top of the script to match it.

I don't think the script would work if you used

$startDirectory = "/home/*/domains/*/public_html/*.html";

$startDirectory = "/home/username";
would be a better choice since the script already does everything below that recursively (so be careful!)

As to your error, make sure your in the same directory as the one you just created the file in. In other words it should be in the list displayed when typing ls
 
jmstacey said:
I don't think the script would work if you used

$startDirectory = "/home/*/domains/*/public_html/*.html";
Jon, I hope I didn't imply that; I certainly didn't mean to.

What I mean to do was to write a perl one liner that would do the change.

However I've decided to not take the risk of doing that unless I log into the server to verify everything myself.

As we probably all know by now, I don't work on servers except under contract.

And I do charge for that.

Jon, I hope you can help Amit as the only way I can take the risk of creating a script for him which would make the change on his server, given his admitted lack of understanding, would be under contract.

Perhaps you can help him through it.

Otherwise we're available.

Jeff
 
Back
Top