PDA

View Full Version : Easy URL Change



symetrix
October 25th, 2003, 05:19 PM
This is a quickie to help change your link codes for TSS.


You will need shell access to your websites. Change to the directory your websites are in and type in the following. After you hit enter, all your links will be updated.perl -pi -e "s/tss.eapps.com/w1.tropicsp.com/g;" *.html


--Mike

Star
October 25th, 2003, 05:25 PM
I have my ftp access and password, but have no idea how to use it. But it sounds like a 5 minute job- so I 'll make sure I don't get billed a few hundo for it

DEWIE42
October 25th, 2003, 05:58 PM
symetrix....that sounds super with over 100 sites I having been going non-stop but ya gotta splain that in BLONDE TERMS LOL.....smileys/smiley2.gifotherwise I will be tempted to drive Redex madsmileys/smiley8.gif Oh I forgot to thank you sorrysmileys/smiley2.gif

MedsDirect
October 25th, 2003, 06:49 PM
Shell acess is a command prompt access, as opposed to ftp. If you dont have command promt access you can download your sites and run some functions on your local computer, then upload the changes.


Dreamweaver and other tools also have global find and replace funtions that can do the job.

Shark Attack
October 25th, 2003, 07:05 PM
Used Dreamweaver - very easy


http://www.lehigh.edu/~www/make_www/IntDreamweaver/find.html

DEWIE42
October 25th, 2003, 07:26 PM
Thanks guys.....have a relative that uses thisDreamweaver program but hasnt had the time to show me as yet ...but I will for sure,because I am very smileys/smiley12.gifand sometimes I just always do things the hard waysmileys/smiley2.gifbut I think its time to start learning the easy way of doing things,of course I use the find and replace with my Coffee Cup Program,and a little of HTML kit but I like Coffee Cup because its like an old slipper to me lol...smileys/smiley4.gif

RxRob
October 25th, 2003, 10:01 PM
I like treesed, myself smileys/smiley4.gif


You can start at /var/www/html and it willreplace text inevery file in every directory below it


./treesed.pl "tss.eapps.com" "w1.tropicsp.com" -tree


Of course, you'll have to create treesed:


type:

pico -w treesed.pl
paste this:


[i]#!/usr/bin/perl

# treesed
# Written January 1996 by Rick Jansen (rick@sara.nl)
# URL: http://www.sara.nl/rick

# usage: treesed pattern1 pattern2 -tree
# treesed pattern1 pattern2 -files file1 file2 ...

# example: treesed href HREF -files *.html

# Treesed searches for pattern1 and replaces pattern1 by pattern2
# if pattern2 supplied. If only pattern1 given treesed just searches.
# Treesed will search in all files and subdirectories of the current
# directory



#--------------------------------------------------------
# Parameters

$DoEdit=0;
$search_pattern = $ARGV[0];
$search_pattern =~ s/(\W)/\\$1/g; # escape regexp chars
shift;

while ($#ARGV >= 0) {

if ($ARGV[0] eq '-files') {
@temp_ls = @ARGV[1 .. $#ARGV];
# Get list of files, skip dirs
foreach $file (@ARGV[1 .. $#ARGV]) {
if (-f $file) {
push(@ls, $file);
}
}
last;
}
elsif ($ARGV[0] eq '-tree') {
&Get_LS;
last;
}

if (! -f $ARGV[0]) {
if (defined($replacement_pattern)) {
print "usage: treesed pattern1 <pattern2> -tree/-files <files>\n";
exit(1);
}

$replacement_pattern = $ARGV[0];
#$replacement_pattern =~ s/(\W)/\\$1/g; # escape regexp chars
$DoEdit=1;
shift;
}

}

# No files?
if ($#ls < 0) {
print "xx No input files\n";
exit(1);
}

print "search_pattern: $search_pattern\n";
print "replacement_pattern: $replacement_pattern\n";
if ($DoEdit) {
print "\n** EDIT MODE!\n\n"; }
else {
print "\n** Search mode\n\n";
}

#foreach $file (@ls) {
# print "$file \n";
#}


#--------------------------------------------------------
# Search list of files for pattern

$linepos=0;

$| = 1; # Force flush after every write
foreach $file (@ls) {
#print "$file\n";
print '.';
$linepos++;
if ($linepos > 50) {
$linepos=0;
print "\n";
}

if (!open(FILE, $file)) {
print "\nCould not open $file\n";
next;
}

$Found = 0;
$Count = 0;
$lineno = 0;
@lines = ();
while (<FILE>) {
$lineno++;
if (/$search_pattern/i) {
#print;
$Count++;
$Found = 1;
push(@lines, $lineno);
}
}
close(FILE);
if ($Found) {
print "\n$file: $Count lines on: @lines\n";
}

if ($Found && $DoEdit) { &Edit($file); }

}
$| = 0;
print "\n";


exit(0);


#--------------------------------------------------------
# Edit file

sub Edit {

# Replace $ARGV[0] with $ARGV[1] in $file

local($file) = @_;
local($bakfile) = $file.'.'.$$;

rxmary
October 25th, 2003, 10:14 PM
thanks RobRx-


Got that Dewie, your on it like white on rice I bet! LOL


just joking you Bread Lady, since you made the blonde joke above, thought I'd fun with ya.

redex
October 26th, 2003, 02:35 AM
f**k RxRob, not bad for a forklift driver smileys/smiley2.gif Way over my head! smileys/smiley16.gif

RxRob
October 26th, 2003, 09:13 AM
I guess I should start reading the topic of the threads I post in then smileys/smiley17.gif