Author Archives: PHPDave

Ways to Move files between 2 IBM is

Pase Shell

  1. rsync
  2. scp -r -3 me@host1:/www/copyme/ me@host2:/www/

iSeries Navigator for windows

  1. Copy and Paste, or Drag and Drop between IBM i’s (sometimes causes sys i to crash)

5250

  1. FTP

Windows

  1. WinSCP,

SSH Mounting w/ local computer

  1. sshfs

Thanks to @jjglyph for the scp idea and @jordiewies for the FTP idea and @theprez for winscp and sshfs.  Its good to know multiple ways

Advertisements

Giving your application eyes ūüĎÄ – Inspired by Common Conference’s talk about Watson

At common this year they seemed to wanted to expand our usage of tools that require Machine Learning or advanced algorithms that take a long time to come up with and may require a lot of processing power to accomplish.  Therefore you send your data offsite via an API to Watson and get back information about your data.  So below are some things I played with.

Given this recent tweet:

Lets see what we could do.  We could have an application that scans a certain hashtag or user and sends the images that person or topic posts about to a cloud service to find out what these services think about it.

Watson – BlueMix – Visual Recognition Demo

https://visual-recognition-demo.mybluemix.net/

Below are the results of submitting this image to Watson and what it thinks about the image. ¬†The first result doesn’t make much sense to me, I’m not sure what a reformer instrument is… but the pommel horse and the gymnastic apparatus are clearly related to what Aaron is attempting. ¬†The 5th and 6th result seem to do with the cover of his computer. ¬†What could we do with this information? ¬†Perhaps you could use it to auto-classify images of an conference without any human resources involved. ¬†So your attendees could see images of things they might find interesting and the photographer only has to worry about snapping interesting photos and not have to worry about the dreaded work of organizing photos.

Watson.png

Google Cloud Vision API

https://cloud.google.com/vision/

As a developer we can’t sit on 1 person or companies view of the IT World. ¬†Therefore I decided to check out what Google’s Cloud vision API saw. ¬†It knew Aaron was human, in a room and doing “physical fitness”. ¬†All very relevant to the picture

Screen Shot 2017-05-11 at 10.02.30 PM.png

It also gave us a what the dominant colors are of the picture and where we could crop the image

Screen Shot 2017-05-11 at 10.03.02 PM.png

One other thing it can provide us is if the image is “safe” to make sure obscene images are not used Screen Shot 2017-05-11 at 10.03.09 PM.png

Tesseract Open Source OCR Engine

https://github.com/tesseract-ocr

Lets say you don’t wait to give your data over to IBM or Google you could look into other repositories that allow you to do the algorithms locally such as tesseract that can be used for OCR. ¬†I’m not sure what other libraries are available for doing the other things that Watson and Google Cloud Vision provide, but I believe the open source community will be coming up with intuitive ideas and perhaps searching more we could find some libraries that can do what IBM and Google are doing.

 

Round 2

Lets see how these services work with a different photo with text and faces turned directly to the camera.

Watson

Can see two males that are 18-24 years old and believes someone is their little brother and someone is their father and perhaps someone is wearing a wet suit (watson will need to improve on picking up skinny jeans.)

Screen Shot 2017-05-11 at 10.24.21 PM.png

Google’s turn

Now what Google was able to do was pretty crazy and I was wondering why Watson isn’t doing this or perhaps it will catch up to google after they have a big enough data set and a proper ML model.

Google was able to identify that the picture had faces expressing Joy! and thinks there’s possibly headwear but there wasn’t. ¬†It also new the roll, tilt and pan of the image which could be used to autocorrect the image to align correctly. ¬†It new the image was taken from twitter and that they were wearing a t-shirt and were having a “Good Time”. ¬†It also had links to web pages where this image could ¬†be found. ¬†It was able to pick up the text on the shirt, and on the marketing displays in the expo. ¬†It could even separate the text into the separate entities in the picture ( the shirt text, the 2 marketing display texts). ¬† It even could keep the text together even though the “o” in “Power” was hidden by some dangling glasses. ¬†It also new that it was a safe image

Screen Shot 2017-05-11 at 10.22.15 PM.png

Screen Shot 2017-05-11 at 10.22.23 PM.png

 

Screen Shot 2017-05-11 at 10.22.35 PM.png

Screen Shot 2017-05-11 at 10.22.44 PM.png

 

Screen Shot 2017-05-11 at 10.22.51 PM.png

 

Screen Shot 2017-05-11 at 10.23.16 PM.png

 

Conclusion

This is the future like it or not, and there’s some crazy applications that we can create when we combine the power of ML of both IBM, Google and open source projects ran locally. ¬† I sort of which we could put pandora’s box away but its already open so we can’t bury our heads in the sand and should start looking into how we can use this innovation for the good of humanity.

 

.

 

Whats going to change when I update PHP on IBM i. PHPinfo is a clue

e Here’s a great little script to see whats going to change when you update PHP on IBM i. ¬†It compares the phpinfo from your production site to your new instance of PHP. ¬†This way you can scroll down and take note of specific differences to PHP. ¬†This isn’t all the changes so there’s more to check but can get you pretty far.

 

https://github.com/brettalton/phpinfo-compare

There is an issue with library lists if your using the PDO_IBM driver.

https://bugs.php.net/bug.php?id=73785

Disable Z-Ray on PHP on IBM i
Edit the file /usr/local/zendphp7/etc/conf.d/zray.ini and change zray.enable=1 to zray.enable=0

; Enable Z-Ray
; zray.enable=1
zray.enable=0

Quickly install ZS9.1 PHP 7.1.3 on your IBM i

I created this simple short shell script to download the current version of Zend Server for IBM i. ¬†Unzip the downloaded zip file and then securely copy the save file to the savf ZENDPHP7 in the QGPL library. ¬†Then we send a remote system command to submit a job to batch to silently restore the savf file. ¬†You’ll have to wait for the batch job to run but afterward it finishes ZS9.1 will be installed in /usr/local/zendphp7

#get the shell script from the gist
wget https://gist.githubusercontent.com/phpdave/9f4090af8b90fa6c3916554b970a63b3/raw/1987d10ad25c885b7a4ebd26523cecce9dba50b1/InstallZS91onIBMi.sh
#modify the user name and IBM i name
vim InstallZS91onIBMi.sh
#Add execute permission to the owner of the file
chmod o+x InstallZS91onIBMi.sh
#run the shell script
./InstallZS91onIBMi.sh

InstallZS91onIBMi.sh Source

Automating deployment of IBM i SQL Database changes to a remote system

If you ever wanted to automate your SQL changes to a remote systems here’s one way of accomplishing that.

First you’ll have to ¬†manually create two local sql files that have the database SQL that you would like to run. ¬†The 1st file up{version#}.sql¬† will be ran when you want to promote your code, and the 2nd file down{version#}.sql will be ran when you want to rollback your changes. ¬†The version# allows you to¬†keep a history of what changes were made each time you this or you could tie it to source control commit#/version#/tag etc.. use whatever helps you.

Now that we have these two files we have to securely send them over to our IBM i.  Simply run this command on your local computer in a shell.  If your on windows install this so you can run it (http://cmder.net/)

scp -r "/sqlsource/migrations" myuser@mysystem.example.com:/sqlsource/migrations

This will recursively copy the local directory /sqlsource/migrations to the remote system mysystem.example.com in the directory /sqlsource/migrations .  This is the directory that must contain our up and down sql scripts.

Now that we have the source on the remote system we need to¬†create two local shell scripts that we’ll send to the remote system and call to promote or rollback the sql. ¬†Create the two files below on your local machine:

PromoteSQL.sh

system -i "RUNSQLSTM SRCSTMF('/sqlsource/migrations/up1.sql') COMMIT(*NONE) NAMING(*SQL)"

RollbackSQL.sh

system -i "RUNSQLSTM SRCSTMF('/sqlsource/migrations/down1.sql') COMMIT(*NONE) NAMING(*SQL)"

We now have the source on the remote server, and 2 local shells scripts that we can send to the remote system. ¬†To actually send the remote command we’ll use this command below on our local machine to send the promotion shell script to the remote system and it’ll execute immediately the shell script that was sent over

ssh myuse@mysystem.example.com < PromoteSQL.sh

If we need to rollback the changes we’ll just use this command:

ssh myuse@mysystem.example.com < RollbackSQL.sh

I’ve kept this example pretty basic, but you can get more extensive by sending parameters to your shell scripts to dynamically tell it what to do. ¬†For example you might want to pass it the environment, the user, the server and this is how you can do that

./promoteAndExecuteSQL.sh dev myuse mysystem.example.com

PromoteAndExecuteSQL.sh

#!/bin/bash
#ZZZPromoteCodeAndDB.sh dev 1205 1206
ENVIRONMENT=${1}
DEPLOYMENTUSER=${2}
DEPLOYMENTSERVER=${3}
echo ${ENVIRONMENT}
echo ${DEPLOYMENTUSER}
echo ${DEPLOYMENTSERVER}
scp -r "/sqlsource/migrations" ${DEPLOYMENTUSER}@${ENVIRONMENT}-${DEPLOYMENTSERVER}:/sqlsource/migrations
ssh ${DEPLOYMENTUSER}@${DEPLOYMENTSERVER} < PromoteSQL.sh