Weblog entry #4 for sneex
#4
My expedition into AMD64: Note 2
Posted by sneex on Thu 28 Jun 2007 at 00:49
My expedition into AMD64: Note 2 ...
OK, so now that I'm done setting up and performance testing the new servers, I need to begin the migration. A little background: I began work here 9 weeks ago, replacing the most recent of about 5 guys who worked here anywhere between 3 weeks to 3 years. All of them have touched the software on the 6 old servers (which these 3 new servers will replace.) A few of the guys who used to work here were programmers of one type or another and I have NO IDEA where all the code is -- very few people left notes. So, after some thinking and digging I remembered another use for the 'locate' command; you know, the one you use in conjunction with updatedb?
Anyways, I know that there are a few hundred PHP, Perl, and related scripts on the old systems, but I have no idea where they all are. So, I wrote the below (modified from a Debian Security Manual shell trick) to, for example, find all the files which have the word 'perl' in them and copy them to a single directory so that I can see what they actually are (note that knowing where they came from at this stage is beside the point.) Once I see which file is what feature I can further refine the search criteria.
for i in { `locate *` }; do [ -f $i ] && { type=`file $i | grep -il perl`; \
[ -n "$type" ] && cp $i ~/Sys.perl.Code; }; done
[ ... the only draw back is that it will copy *all* files which have perl in them, regardless of whether or not they are 'text' scripts or 'gif' binaries... ]
More later...
-Sx-
OK, so now that I'm done setting up and performance testing the new servers, I need to begin the migration. A little background: I began work here 9 weeks ago, replacing the most recent of about 5 guys who worked here anywhere between 3 weeks to 3 years. All of them have touched the software on the 6 old servers (which these 3 new servers will replace.) A few of the guys who used to work here were programmers of one type or another and I have NO IDEA where all the code is -- very few people left notes. So, after some thinking and digging I remembered another use for the 'locate' command; you know, the one you use in conjunction with updatedb?
Anyways, I know that there are a few hundred PHP, Perl, and related scripts on the old systems, but I have no idea where they all are. So, I wrote the below (modified from a Debian Security Manual shell trick) to, for example, find all the files which have the word 'perl' in them and copy them to a single directory so that I can see what they actually are (note that knowing where they came from at this stage is beside the point.) Once I see which file is what feature I can further refine the search criteria.
for i in { `locate *` }; do [ -f $i ] && { type=`file $i | grep -il perl`; \
[ -n "$type" ] && cp $i ~/Sys.perl.Code; }; done
[ ... the only draw back is that it will copy *all* files which have perl in them, regardless of whether or not they are 'text' scripts or 'gif' binaries... ]
More later...
-Sx-
Comments on this Entry
you could use file to see if it is a perl executable. It should be a bit slower though.
[ Parent | Reply to this comment ]
Actually on the new Debian systems the file command already does that, therefore this shell trick works as expected on Debian 4. However, and the reason I said what I did about 'perl text scripts' versus other file types, apparently on RedHat 9 (the system I'm migrating from) this stupid shell trick grabs all files that have 'perl' in them. But after working it out on 6 servers running thousands of programs I'm starting to not care about that side effect.
I still have a couple of hundred programs to go through ... where is Data when you need him?
-Sx-
http://youve-reached-the.endoftheinternet.org/
I still have a couple of hundred programs to go through ... where is Data when you need him?
-Sx-
http://youve-reached-the.endoftheinternet.org/
[ Parent | Reply to this comment ]
Posted by Anonymous (85.22.xx.xx) on Thu 28 Jun 2007 at 18:56
Instead of copying the resulting files, you could create symlinks. This saves disk space, is faster and the best part:
ls -l will show you the actual place of the file.
[ Parent | Reply to this comment ]