I'm using the Magento 1.9.1 and trying to install some patches. I followed the guide online and I have the installation result like the following:

sh PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh -R
PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 14: PATCH_SUPEE-      5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 127: not found
PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 14: PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 127: not found
PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 25: PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 0: not found
Checking if patch can be applied/reverted successfully...
Patch was applied/reverted successfully.

Obviously, its successful. The Patch is:SUPEE-5344, it can be found here, https://www.magentocommerce.com/products/downloads/magento/

However, I have 3 lines of error or something.. I don't think know what it is....

I'm using ubuntu and I suppose this has something to do with the fact that ubuntu has the default dash for sh instead of bash. But the patch file wants bash.

Anyone can help me understand this 3 lines?

if I run it with the -x, the result is:

sh -x PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh 
+ REQUIRED_UTILS=sed patch
+ _check_installed_tools sed patch
+ local missed=
+ [ -z sed ]
+ type -t sed
+ 127 != 0
PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 14: PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 127: not found
+ shift
+ [ -z patch ]
+ type -t patch
+ 127 != 0
PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 14: PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 127: not found
+ shift
+ [ -z  ]
+ echo
+ MISSED_REQUIRED_TOOLS=
+ echo
+ wc -w
+ 0
PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 25: PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: 0: not found
+ which cat
+ CAT_BIN=/bin/cat
+ which patch
+ PATCH_BIN=/usr/bin/patch
+ which sed
+ SED_BIN=/bin/sed
+ which pwd
+ PWD_BIN=/bin/pwd
+ which basename
+ BASENAME_BIN=/usr/bin/basename
+ /usr/bin/basename PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh
+ BASE_NAME=PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh
+ [  = -? -o  = -h -o  = --help ]
+ REVERT_FLAG=
+ SHOW_APPLIED_LIST=0
+ [  = -R -o  = --revert ]
+ [  = --list ]
+ /bin/pwd
+ CURRENT_DIR=/var/www/html/magento/
+ echo /var/www/html/magento/app/etc/
+ APP_ETC_DIR=/var/www/html/magento/app/etc/
+ echo /var/www/html/magento/app/etc/applied.patches.list
+ APPLIED_PATCHES_LIST_FILE=/var/www/html/magento/app/etc/applied.patches.list
+ [ 0 -eq 1 ]
+ _check_files
+ [ ! -e /var/www/html/magento/app/etc/ ]
+ [ ! -w /var/www/html/magento/app/etc/ ]
+ [ -e /var/www/html/magento/app/etc/applied.patches.list ]
+ [ ! -w /var/www/html/magento/app/etc/applied.patches.list ]
+ /bin/sed -n /^__PATCHFILE_FOLLOWS__$/= /var/www/html/magento/PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh
+ SKIP_LINES=163
+ ADDITIONAL_INFO_LINE=160p
+ REVERTED_PATCH_MARK=
+ [ -n  ]
+ _apply_revert_patch dry-run
+ DRY_RUN_FLAG=
+ [ dry-run = dry-run ]
+ DRY_RUN_FLAG= --dry-run
+ echo Checking if patch can be applied/reverted successfully...
Checking if patch can be applied/reverted successfully...
+ + /usr/bin/patch --dry-run -p0
/bin/sed -e 1,/^__PATCHFILE_FOLLOWS__$/d /var/www/html/magento/PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh
+ PATCH_APPLY_REVERT_RESULT=checking file app/code/core/Mage/Admin/Model/Observer.php
checking file app/code/core/Mage/Core/Controller/Request/Http.php
checking file app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php
checking file app/code/core/Mage/XmlConnect/Model/Observer.php
checking file lib/Varien/Db/Adapter/Pdo/Mysql.php
+ PATCH_APPLY_REVERT_STATUS=0
+ [ 0 -eq 1 ]
+ [ 0 -eq 2 ]
+ _apply_revert_patch
+ DRY_RUN_FLAG=
+ [  = dry-run ]
+ + /usr/bin/patch -p0
/bin/sed -e 1,/^__PATCHFILE_FOLLOWS__$/d /var/www/html/magento/PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh
+ PATCH_APPLY_REVERT_RESULT=patching file app/code/core/Mage/Admin/Model/Observer.php
patching file app/code/core/Mage/Core/Controller/Request/Http.php
patching file app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php
patching file app/code/core/Mage/XmlConnect/Model/Observer.php
patching file lib/Varien/Db/Adapter/Pdo/Mysql.php
+ PATCH_APPLY_REVERT_STATUS=0
+ [ 0 -eq 1 ]
+ [ 0 -eq 2 ]
+ echo Patch was applied/reverted successfully.
Patch was applied/reverted successfully.
+ /bin/sed -n 160p /var/www/html/magento/PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh
+ ADDITIONAL_INFO=SUPEE-5344 | EE_1.14.1.0 | v1 | a5c9abcb6a387aabd6b33ebcb79f6b7a97bbde77 | Thu Feb 5 19:14:49 2015 +0200 | v1.14.1.0..HEAD
+ date -u +%F %T UTC
+ APPLIED_REVERTED_ON_DATE=2015-04-17 00:45:22 UTC
+ echo -n 2015-04-17 00:45:22 UTC | SUPEE-5344 | EE_1.14.1.0 | v1 | a5c9abcb6a387aabd6b33ebcb79f6b7a97bbde77 | Thu Feb 5 19:14:49 2015 +0200 | v1.14.1.0..HEAD
+ APPLIED_REVERTED_PATCH_INFO=2015-04-17 00:45:22 UTC | SUPEE-5344 | EE_1.14.1.0 | v1 | a5c9abcb6a387aabd6b33ebcb79f6b7a97bbde77 | Thu Feb 5 19:14:49 2015 +0200 | v1.14.1.0..HEAD
+ echo -e 2015-04-17 00:45:22 UTC | SUPEE-5344 | EE_1.14.1.0 | v1 | a5c9abcb6a387aabd6b33ebcb79f6b7a97bbde77 | Thu Feb 5 19:14:49 2015 +0200 | v1.14.1.0..HEAD\npatching file app/code/core/Mage/Admin/Model/Observer.php
patching file app/code/core/Mage/Core/Controller/Request/Http.php
patching file app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizeController.php
patching file app/code/core/Mage/XmlConnect/Model/Observer.php
patching file lib/Varien/Db/Adapter/Pdo/Mysql.php\n\n
+ exit 0
  • Could you post the contents of the patch? that way its easier to determine what the issue may be as "not found" could be custom generated, but tells us nothing. – Shaughn Apr 16 '15 at 23:05
  • @Shaughn The Patch is SUPEE-5344. Its an .sh file, you can easily open it with any editor. – Fan Zhang Apr 17 '15 at 0:05
  • I have run this several times and i get the same successful result "Checking if patch can be applied/reverted successfully... Patch was applied/reverted successfully." every time. I see you are running it with the "-R" option which is to revert the patch, have you tried without it? – Shaughn Apr 17 '15 at 0:17
  • Run the patch using verbose option and see where those errors get displayed: sh -x PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh – Shaughn Apr 17 '15 at 0:33
  • @Shaughn its the same if I run it without "-R". I updated the result for running with -x – Fan Zhang Apr 17 '15 at 0:47

Lines 14 and 25 contain some code that only works with bash, not with sh.

You're running into this problem because the file is a bash script, but you're running it with sh. On many servers sh is the same as bash, but that doesn't seem to be the case with your environment.

  • I'm running Ubuntu 14.04 and the default implementation is dash, instead of bash. Do I need to worry about it? – Fan Zhang Apr 17 '15 at 16:14
  • Nope i dont think thats the case here, i took the patch and tested it on multiple unix systems and i got the same success result without issues. – Shaughn Apr 17 '15 at 22:19
  • @Shaughn This issue bothers me...What are the unix system you are testing on? Any Ubuntu ? – Fan Zhang Apr 18 '15 at 17:11
  • I've tested on a local Ubuntu install, Mac OSX and 2 linux servers (Centos, Debian) and when i ran the patch, it worked without the issue lines being outputted. – Shaughn Apr 20 '15 at 8:41
  • Replacing sh PATCH_SUPEE-... by bash PATCH_SUPEE-... worked for me. If you already ran the command with shbe sure to revert it with sh command : sh PATCH_SUPEE-XXX -R. Some of the files may have been changed. – Cladiuss Apr 3 at 14:49

on Ubuntu I ran this

  # chmod +x PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh

then

# ./PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh
    Checking if patch can be applied/reverted successfully...
    Patch was applied/reverted successfully.

If your told Error! Some required system tools, that are utilized in this sh script, are not installed: Tool(s) "patch" is(are) missed, please install it(them).

sudo apt-get install patch

Then re-run

./PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh
  • This definitely worked! Had the exact same issue as stated above and this fixed it! Recommended Answer! – Lemonade Apr 20 '15 at 18:27
  • 1
    I did what you suggested: changed the file to +x mode and run the file directly. Bingo! No that 3 lines of errors. However, do you know why this is happening? I mean, what's the difference between run it directly with ./ and run it with sh? – Fan Zhang Apr 21 '15 at 0:42
  • It looks like that runing with sh will use different "things"(maybe dash) than running with ./(maybe bash). I read this somewhere else ""In Ubuntu 6.10, the default system shell, /bin/sh, was changed to dash (the Debian Almquist Shell); previously it had been bash (the GNU Bourne-Again Shell). "" – Fan Zhang Apr 21 '15 at 0:54

Ok so i had a look at this over the weekend and found that it seems to be outputting the portion of code that checks system tools.

To test do the following in your Magento root folder:

nano test.sh

add the following code to test.sh:

#!/bin/bash
# Patch apllying tool template
# v0.1.2
# (c) Copyright 2013. Magento Inc.
#
# DO NOT CHANGE ANY LINE IN THIS FILE.

# 1. Check required system tools
_check_installed_tools() {
    local missed=""

    until [ -z "$1" ]; do
        type -t $1 >/dev/null 2>/dev/null
        if (( $? != 0 )); then
            missed="$missed $1"
        fi
        shift
    done

    echo $missed
}

REQUIRED_UTILS='sed patch'
MISSED_REQUIRED_TOOLS=`_check_installed_tools $REQUIRED_UTILS`
if (( `echo $MISSED_REQUIRED_TOOLS | wc -w` > 0 ));
then
    echo -e "Error! Some required system tools, that are utilized in this sh script, are not installed:\nTool(s) \"$MISSED_REQUIRED_TOOLS\" is(are) missed, please install it(them)."
    exit 1
fi

You will notice that this is an extract of the first part of the patch.

Once added, save the file and run it in root Magento as you would have done with the patch except with the verbose -x:

sh -x test.sh

For me it outputs the following:

slghatlen@user27-pc ~/sites/ce_1.9.1.0_working: sh -x test.sh 
+ REQUIRED_UTILS='sed patch'
++ _check_installed_tools sed patch
++ local missed=
++ '[' -z sed ']'
++ type -t sed
++ ((  0 != 0  ))
++ shift
++ '[' -z patch ']'
++ type -t patch
++ ((  0 != 0  ))
++ shift
++ '[' -z '' ']'
++ echo
+ MISSED_REQUIRED_TOOLS=
++ echo
++ wc -w
+ ((         0 > 0  ))

And, you should output the following / similar:

sh -x test.sh 
+ REQUIRED_UTILS=sed patch
+ _check_installed_tools sed patch
+ local missed=
+ [ -z sed ]
+ type -t sed
+ 127 != 0
test.sh: 14: test.sh: 127: not found
+ shift
+ [ -z patch ]
+ type -t patch
+ 127 != 0
test: 14: test.sh: 127: not found
+ shift
+ [ -z  ]
+ echo
+ MISSED_REQUIRED_TOOLS=
+ echo
+ wc -w
+ 0
test.sh: 25: test.sh: 0: not found

If this is true, then i would assume the issue is one of 3 things (take into account, i am not a pro at bash scripting):

  1. the issue exists in the conditional statement,
  2. or, you are in fact missing the required tools,
  3. or, your system outputs the commands differently to what is expected in the script where the script itself doesn't take systems, custom builds, etc into account.

Im leaning towards point 3, which in this case, is actually nothing to worry about.

  • I ran the test script, and it's exactly as the second output you posted here. I tried the suggestion of @David Allsop. use chmod +x test.sh and then run the ./test.sh. It output nothing. I assume it means its running smoothly...It looks like that, in ubuntu, using sh test.sh and ./test.sh will calling different different "thing" to execute the script. – Fan Zhang Apr 21 '15 at 0:49
  • Ye, so i believe @David is right, normally i will run the script as the user assigned to it with sh test.sh, i never run as ./test.sh or dir/test.sh as it almost never works for me. I think David hit it on the head with this one, Good Job – Shaughn Apr 21 '15 at 8:37
  • What's the difference between running sh and ./ ? @Shaughn – Fan Zhang Apr 21 '15 at 20:06
  • Sorry, i meant "sh ./test.sh" and "sh dir/test.sh" – Shaughn Apr 21 '15 at 20:46

try running the script directly like "./PATCH[...]" and not with "sh PATCH[...]". This may show you missing packages like "patch".

  • I'm trying to run it directly, and its wired:"-bash: ./PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: Permission denied". I don't understand why its saying -bash.. I have ubuntu and the default should be dash.. Also, I tried the sudo, it say "sudo: ./PATCH_SUPEE-5344_CE_1.8.0.0_v1-2015-02-10-08-10-38.sh: command not found" – Fan Zhang Apr 17 '15 at 17:00

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.