Wondering where Pair networks keeps bash hidden?
I was frustrated. I had spent the weekend on a bash script for a client hosting with Pair networks and NOTHING was working properly. Their old and moldy MYSQL 5.0 required I come at a certain client-problem from a rather tedious angle that needed bash to parse a lot of lines returned from a MYSQL command-line query in somewhat sophisticated ways. My first problem was that the MYSQL commands wouldn’t run. This is because Pair actually has my MYSQL and database related things going on another machine. So to run a mysql command, I needed to add some info beyond what I needed in my dev setup:
mysql -hYOURDBSERVER.pair.com -uUSERNAME -pPASSWORD -e 'SHOW FULL PROCESSLIST;'
The important part here is your server location at the top of the mysql command. Make sure you don’t miss the -h that leads it. Without a space, you might be confused into thinking your server is hdb123.pair.com, but it’s important to note that the -h part is a flag followed by your db123.pair.com as an argument. Another note is to make sure to add a hyphen before the “e” flag on the MYSQL statement. Pair likes it hyphenated…
My next problem was a stubborn refusal from the shell at bin/sh to process arrays. Whenever I tried array-functions in the shell script, I got this error:
declare: not found
Removing the declare got past that, but then when the array was being split up, I got THIS error:
Syntax error: word unexpected (expecting ")")
Though this worked on my local box, this fails utterly in the pair environment. To work around this, we must make sure to invoke the correct shell: bash.
If you are using the generic /bin/sh path, you might discover things like arrays and executions of mysql from the bash environment aren’t working correctly. Locate the binary by typing:
Mine was here:
Now my shell script is running and my client is protected against a serious error that was killing her app.