Linux Global Substitutions Primer Tutorial

Linux Global Substitutions Primer Tutorial

Linux Global Substitutions Primer Tutorial

We’ve discussed the topic of Linux (or unix) shell scripting method of global file substitutions with the very old Are you interested in combating drudgery? and the example usage in str_replace.sh

Yesterday we revisited the idea regarding the upgrade to PHP 5.4 recently, and its affect on the osCommerce sample data website we have here at the www.rjmprogramming.com.au domain.

This PHP: Deprecated features in PHP 5.3.x – Manual link outlines some of the issues we tackled using global substitution methods.

So, with these deprecated features in mind we came up with the Korn Shell scripting code you could call oscommerce.ksh as you can see below …


#!/bin/ksh
# oscommerce.ksh
# Changes to osCommerce code to fix for PHP 5.4 ...
# PHP: Deprecated features in PHP 5.3.x - Manual
# //php.net/manual/en/migration53.deprecated.php
if [ ! -z "$1" ]; then
files=$(grep -rl HTTP_POST_VARS ${1}) && echo $files | xargs sed -i 's/HTTP_POST_VARS/_POST/g'
files=$(grep -rl HTTP_COOKIE_VARS ${1}) && echo $files | xargs sed -i 's/HTTP_COOKIE_VARS/_COOKIE/g'
files=$(grep -rl HTTP_GET_VARS ${1}) && echo $files | xargs sed -i 's/HTTP_GET_VARS/_POST/g'
files=$(grep -rl HTTP_SERVER_VARS ${1}) && echo $files | xargs sed -i 's/HTTP_SERVER_VARS/_SERVER/g'
files=$(grep -rl HTTP_ENV_VARS ${1}) && echo $files | xargs sed -i 's/HTTP_ENV_VARS/_ENV/g'
files=$(grep -rl HTTP_SESSION_VARS ${1}) && echo $files | xargs sed -i 's/HTTP_SESSION_VARS/_SESSION/g'
files=$(grep -rl HTTP_POST_FILES ${1}) && echo $files | xargs sed -i 's/HTTP_POST_FILES/_FILES/g'
files=$(grep -rl HTTP_REQUEST_VARS ${1}) && echo $files | xargs sed -i 's/HTTP_REQUEST_VARS/_REQUEST/g'
else
echo "Please add a path of interest"
fi
exit

… and we also include a version that would work for Mac OS X environments that have an additional parameter for sed shown with oscommerce_mac.ksh

Of great help with the ideas of this script was this link … thanks.

Below are links to information regarding some of the Linux commands used in the script …

… enjoy today’s tutorial, and hope to see you again soon.

If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , , , , , , . Bookmark the permalink.

13 Responses to Linux Global Substitutions Primer Tutorial

  1. Carlos Simi says:

    Hey, you used to write great, but the last several posts have been kinda boring… I miss your great writings. Past several posts are just a bit out of track! come on!

  2. I carry on listening to the rumor speak about receiving free online grant applications so I have been looking around for the most excellent site to get one. Could you advise me please, where could i acquire some?

  3. of course like your web site however you have to check the spelling on quite a few of your posts. Several of them are rife with spelling issues and I to find it very bothersome to inform the truth nevertheless I‘¦ll surely come back again.

  4. Personal growth quotes says:

    There is noticeably a bundle to find out about this. I assume you produced confident excellent factors in functions also.

    http://rockyroy0412.tumblr.com/post/142228023246/personal-spiritual-self-development-and-growth

  5. Healthy Kids says:

    Thanks a lot for giving everyone an exceptionally remarkable chance to read from this blog. It is always so brilliant plus full of fun for me and my office fellow workers to visit the blog at minimum three times per week to see the new issues you have got. Of course, we are always astounded concerning the superb suggestions served by you. Certain 2 areas in this posting are completely the best we have all ever had.

  6. I have recently started a website, the info you provide on this web site has helped me greatly. Thank you for all of your time & work.

  7. Easy Money says:

    It‘¦s in point of fact a nice and useful piece of information. I am glad that you shared this useful information with us. Please keep us up to date like this. Thank you for sharing.

  8. Excellent blog right here odpdoss! Additionally your website so much up fast! What web host are you using? Can I am getting your associate hyperlink to your host? I want my site loaded up as fast as yours lol

  9. I was just searching for this information for some time. After 6 hours of continuous Googleing, finally I got it in your website. I wonder what is the lack of Google strategy that don’t rank this kind of informative websites in top of the list. Normally the top sites are full of garbage.

  10. A lot of thanks for all your effort on this web site. My aunt delights in doing internet research and it is easy to understand why. My partner and i notice all of the dynamic manner you present worthwhile tips by means of your blog and therefore foster participation from website visitors on the subject so our favorite daughter is without a doubt starting to learn a lot. Have fun with the remaining portion of the year. You are conducting a dazzling job.

  11. amigurumi says:

    I visit every day some web sites and websites to read articles or reviews, but this weblog provides feature based writing.|

  12. Livia Ocejo says:

    I conceive this website holds some very excellent information for everyone :D. “Nothing surely is so disgraceful to society and to individuals as unmeaning wastefulness.” by Count Benjamin Thompson Rumford.

  13. Good write-up, I’m regular visitor of one’s site, maintain up the excellent operate, and It’s going to be a regular visitor for a long time.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>