Welcome to thatlinuxbox.com Friday, April 10 2020 @ 07:49 PM UTC

Specify QUERY_STRING to PHP CLI

View Printable Version
  • Sunday, December 02 2012 @ 03:25 PM UTC
  • Contributed by:
  • Views: 7,206
Linux, Open Source, and Tech Stuff

Share
  • Google Plus
  • Facebook
  • Twitter
  • Reddit
  • LinkedIn
  • Digg

Thanks to an ancient http://PHP.net comment (http://www.php.net/manual/en/features....php#26201) and a Joomla! forum post (http://forum.joomla.org/viewtopic.php...3#p1318363), I was able to figure out how to run a Joomla php script from the command line and
specify query parameters *without* having to modify any of the PHP code to parse the arguments / options. Most of the examples on the net suggest modifying the PHP script to parse the argv options. I also did not have luck using environment variables to specify QUERY_STRING.

For example, take a Joomla! article with a URL something like this:

mysite/index.php?option=com_content&id=10

Many people running Joomla have SEO-friendly URLs enabled, but the above is the simple (simplest?) query string to get to a particular article using the article id.

Now we can test a particular article at this site from the command line.

Change directory to the appropriate document root and run php as a command-line program:

$ php index.php '&option=com_content&id=10'

The magic sauce is that the first character of the query argument list is just another ampersand rather than the traditional question mark.

Why would I want to do this at all? As one of the Linux system administrators responsible for helping our University customers with their hosted web sites, I sometimes have to debug unusual issues. Having system administrators modify production customer code is not standard practice and unfortunately some of our web hosting customers are not saavy enough to debug unusual issues themselves. One of the tools in our sysadmin toolbox is strace. If I can get the script to repeat the behavior in the command line while strace is running I can often determine the cause of the issue. Running the script in the cli is frequently much easier than trying to catch the issue with strace on a live production site, in shared web infrastructure, etc. We can see file accesses failing, network requests to external servers that don't allow the php page to render until after the remote content is fetched, slow performance from a mysql database... all via the output of strace.

Cluster SSH

View Printable Version
  • Wednesday, January 25 2012 @ 12:05 AM UTC
  • Contributed by:
  • Views: 8,012
Linux, Open Source, and Tech Stuff

Share
  • Google Plus
  • Facebook
  • Twitter
  • Reddit
  • LinkedIn
  • Digg

ClusterSSH is a nice tool for manipulating multiple *nix machines simultaneously. For example, if I want to run some commands on two Linux machines named server1 and server2, I could:

# cssh server1 server2

And I will get two xterm windows that I can control simultaneously by typing into the cssh command window. Since cssh will send keystrokes to both servers, any series of commands can be run, including editing files, etc. I have found that my daily patterns of behavior make cssh preferable to similar tools such as pdsh. Also, cssh uses very similar options syntax to the ssh command, so I don't have to remember different options (I frequently use -l and -p).

I might want to tail the logs on all of the machines in the cluster, but then focus in on one particular machine after I have identified a particular cluster node of interest. Similarly, I might work out a long command line on a single node before running it on the rest of the machines via the cssh command window.

In Debian and Ubuntu, cssh can be installed with:

# sudo apt-get install clusterssh

Cluster SSH is also available for Mac OS X (http://code.google.com/p/csshx/).

A clusterssh package seems to be working its way into Red Hat flavors via Extras or 3rd party repos such as rpmforge.

After running cssh for the first time, you will have a .csshrc file in your home directory. This file can be tweaked in various ways to make connecting to groups of machines easier. To save a group of machines into a list that you can re-use, cssh can use a plain text cluster file.

To use a cluster file:

 

 

GatorLUG Codeslinger Programming Contest - Fall 2011

View Printable Version
  • Friday, November 18 2011 @ 05:56 PM UTC
  • Contributed by:
  • Views: 3,549
Linux, Open Source, and Tech Stuff

Share
  • Google Plus
  • Facebook
  • Twitter
  • Reddit
  • LinkedIn
  • Digg

This week I participated in a programming contest hosted by the local Linux User Group, the GatorLUG.



The contest was sponsored by a local Gainesville company, Main Street Softworks, who make the Monetra payment processing software.

Contestants received these really nice t-shirts:

Upgrading to PHP 5.3 on CentOS 5.x

View Printable Version
  • Wednesday, June 29 2011 @ 02:11 AM UTC
  • Contributed by:
  • Views: 4,072
Linux, Open Source, and Tech Stuff

Share
  • Google Plus
  • Facebook
  • Twitter
  • Reddit
  • LinkedIn
  • Digg

I ran into a dependency issue trying to upgrade a particular PHP application to the latest version. Geeklog 1.8.0 requires PHP 5.2 or higher.

The default PHP packages in Centos 5.x are apparently based on the older PHP 5.1 branch. To upgrade php, just remove php and install the specific PHP 5.3 packages:

# yum remove php-common

# yum install php53-common

and any additional php packages needed such as php53-mysql, php53-pdo, ...

Shuttle XPC Glamor replacement power supply

View Printable Version
  • Tuesday, June 28 2011 @ 11:35 PM UTC
  • Contributed by:
  • Views: 22,365
Linux, Open Source, and Tech Stuff

Share
  • Google Plus
  • Facebook
  • Twitter
  • Reddit
  • LinkedIn
  • Digg

A few weeks ago the power supply died in my Shuttle Glamor XPC SN78SH7 HTPC / home server. The small Shuttle came with a 300 Watt power supply and since I have two hard drives and tend to run the server day and night, I decided to go ahead and upgrade to a 500 Watt power supply.

The original 300 Watt PC61 power supply was labeled with the following information:

Shuttle P/N: PPR-PC6100-L000
PC6100L-######### REV.01
MODEL NO: PC61I0002

This is a photo of the dead power supply:



I did my best to locate a cheap replacement, possibly a generic component. I was not able to locate one on the web that I was confident would work with this small case. I found the official Shuttle replacement parts listed in a PDF at the Shuttle web site. Even after I located the part I wanted, there were not many vendors who had the part in stock.

Here is a photo of the official Shuttle PSU replacement part:

User Functions

Login

Connect

thatlinuxbox.com is the home of Dan Stoner's Personal Blog, Photos, and More (opinions, rants, techno-babble, and possibly a few useful tidbits of knowledge).

Questions or Comments about this site? Contact danstoner _ at _ gmail.com.

RSS Feed for this blog

Other places to find me on the web:

Twitter

LinkedIn

GitHub

Support This Site

If you like something that you find on this site, please consider making a purchase through one of the links below or sending me an item from my Amazon Wish List.


The Clymb


Awesome VPS hosting by Linode.com