2

I have this shell script to install ionCube loader:

if [[ $(id -u) -ne 0 ]] ; then echo "Please run as root" ; exit 1 ; fi
echo "Welcome to this script to install the ionCube loader on CentOS!"
cd /usr/local/src
wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar zxvf ioncube_loaders_lin_x86-64.tar.gz
cd  ioncube
mkdir /usr/local/ioncube
echo "Please specify which PHP version you are using (e.g.: 5.3)."
read version
cp ioncube_loader_lin_"$version".so /usr/local/ioncube
path=$(php -i|grep php.ini | awk 'NR==2{print $5}')
read path
echo "zend_extension = /usr/local/ioncube/ioncube_loader_lin_"$version".so" >> "$path"

When I try to run it on CentOS 6.5 Final with this PHP version (php -v):

PHP 5.3.28 (cli) (built: Jun 23 2014 16:25:09) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies

I get the following error:

./ioncube.sh: line 17: : File or folder doesn't exist

Line 17:

echo "zend_extension = /usr/local/ioncube/ioncube_loader_lin_"$version".so" >> "$path"

The error says that $path doesn't exist. When I try to manually run the command of $path (php -i|grep php.ini | awk 'NR==2{print $5}'), the output is:

/usr/local/lib/php.ini

When I try to run line 17 but replace $path with the actual output of the command (of course I'll replace $version too):

echo "zend_extension = /usr/local/ioncube/ioncube_loader_lin_"5.3".so" >> "/usr/local/lib/php.ini"

The command succeeds.

I don't understand what's wrong here.

1

The problem is the read path. While one line creates the $path variable, the next sets it to blank again:

## This line will set the $path variable.
path=$(php -i|grep php.ini | awk 'NR==2{print $5}')
## This one expects to read the value of $path from standard input 
## so it sets it to empty unless input is given.
read path

You can test this by adding echo "$path" after line 17 and also after the read path. You'll see that the second prints an empty string. You can also see that that's the problem in your error message:

./ioncube.sh: line 17: : File or folder doesn't exist
                     ---
                      |---------> this should be the file name

So, just delete the read path line.

  • Interesting, didn't know that. It works now, thanks :) – William Edwards Aug 23 '14 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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