How run a bash script in it’s directory

Posted by admin on November 18, 2017
linux / No Comments

To run a script in it’s directory and not in the directory we’re calling it, we can use the dirname command, pass their result to a variable, cd to the path and then execute the tasks.

# Here we pass the dirname to a variable
dirname=`dirname $0`

# Change current directori
cd $dirname

# Execute the task, in this case, copy html files and save them as php files
for file in ./*.html; do
#cp ./mondial.* ./"$file"
cp $file "${file/html/php}"

I hope this little script be useful to you.


Tags: , ,

Connect Sql Server 5.6 from Php in Linux CentOS 6

Posted by admin on March 28, 2016
sql server / No Comments

To connect to SQL Server from Linux use this command to install the driver:

$ sudo yum install -y php-mssql

For example, to php5.6:

$ sudo yum install -y php56w-mssql

This command installs freetds , a collection of libraries to connect to SQL Server from Linux. With this library we can not only connect from Php, but from the command line with the tsql program.

After installing, do not forget to restart apache:

$ sudo apachectl restart

Happy coding 🙂

Tags: , , , , , , ,

Upgrading PHP to 5.6 in linux Centos 6

Posted by admin on March 27, 2016
Php / No Comments

Php by default in Centos 6 may be versión 5.3. If you want to make the most of php with useful functions lie hex2bin, you need the 5.6 version.

In order to upgrade, first we must add the repo, then remove the current version and finally install the new version.

This script contains the commands needed to carry out the tasks:

sudo rpm -Uvh
sudo yum remove php-common
sudo yum install php56w
sudo yum install php56w-mysql
sudo yum install php56w-common
sudo yum install php56w-pdo
sudo yum install php56w-opcache
sudo yum install php56w-pgsql
sudo yum install php56w-pear
sudo yum install php56w-mcrypt
sudo yum install php56w-xml
sudo yum install php56w-xmlrpc
sudo yum install php56w-devel
sudo yum install php56w-pecl-memcache
sudo yum install php56w-gd
sudo yum install php56w-pspell
sudo yum install php56w-snmp
php --version               

With the last line we can verify the success of the upgrade.

Happy coding! 🙂

Tags: , , , , ,