earth tech

[software and hardware technology originating from or otherwise pertinent to planet earth]

use these buttons to share this blog on portal sites:

Add to Google

Friday, July 31, 2009

 

MySQL script execution

The following is text copied from the mysql(3) manual page:

You can execute SQL statements in a script file (batch file) like this:

   shell> mysql db_name < script.sql > output.tab

The MySQL version 5.x and greater also provide a mysqldump which has an XML output switch. This causes mysqldump to output XML on stdout such that the mysqldump output can be used directly in an XML document output stream.

Labels: , ,

Tuesday, July 14, 2009

 

Bash PS1 Prompt Set [correction]

http://www.gnu.org/software/bash/manual/bashref.html

##
## Set that annoying Cygwin Bash prompt...;)
##
##   There was an error in this string the previously 
##   published version - here is the corrected version.
##   This is Bash shell script code; it should go in the
##   file ~/.bashrc in the user's HOME directory - it 
##   could also go in  /etc/bashrc
##
export PS1='\[\033[32m\]\u@\h: \[\033[33m\w\033[0m\]
\$'

Labels: , , , , ,

Sunday, May 24, 2009

 

PHP Modules: Finding Syntax Errors and Module Dependencies

http://php.net/

In constructing a web application with more than 2 PHP source modules, I found that it is useful to have a quick and easy way of finding a syntax error that may exist in one (or more) of a list of included modules.

Getting a List of PHP Includes

There is a function in PHP for this, which we will get back to in a moment. For right now I wanted to address some things we can do at a Bash prompt to troubleshoot why a script may not be sending any output to the browser on STDOUT.

That's a very common situation when you're working on a large application with many modules. It becomes important in those situations to be meticulous about syntax checking each change in any code before making additional changes.

I've been using the 'Lint' mechanism provided by PHP to syntax check PHP source code. It works like this: 

  $php -l <fileName>

Now, some of you might already be seeing the implications of this. Hows about: 

$for fn in \
      `grep require frmPlayerInformation_body.09.inc\
      | perl -ne '/\"([a-zA-Z0-9.]+)\"\;/ && print "$1\n";'` ;;
 do 
      echo $fn ;;
      php -l $fn ;;
      echo "########" ;;
 done

The implications for scripting this operation from the command line are clear.

get_included_files()

PHP provides a function to get a list of module dependencies for a running script. It's called

get_included_files()

… and here's the URL for the docs: http://us2.php.net/manual/en/function.get-included-files.php

Problems with this Approach

There is at least one serious deficiency inherent in using the require, require_once, include, and include_once directives as the sole indicators of module dependency;  that is that, simply, the modules which are required or "included" due to HTML element attribute values.

Examples include the ACTION attrubute value(s) of HTML FORM element(s), the SRC attribute values for SCRIPT elements. and so on. IFRAME and LINK elements are also among those that can cause a module dependency within the HTML, CSS, or Javascript layer(s) generated by PHP code of a site.

Labels: , , , , , , , , , , ,

Saturday, May 16, 2009

 

Transparent SSH Login

Labels: , , , , , , , , , , , ,

Wednesday, May 6, 2009

 

ls2csv.pl

#!/usr/bin/perl -w
#
# ls2csv.pl - show a listing of the PHP file
#            (*.inc and *.php) 
#             as a CSV table; no table headings included in 
#             output; no params defined
#
sub create_listing($) 
{
  my $xtn = shift;
  my @files = `ls -ghoG *.$xtn`;
  foreach my $f (@files) {
    chomp($f);
    $f =~ s/^\s*[-rw]+\s+\d\s+(.+)/$1/;
    $f =~ s/ /\",\"/g;
    $f =~ s/^(.)/\"$1/;
    $f =~ s/(.)$/$1\"/;
    print "$f\n";
  }
}

map { create_listing($_) } ("inc","php");

Labels: , , , , , , , ,

Archives

2006/12   2007/01   2007/05   2007/06   2007/07   2007/08   2007/10   2008/01   2008/02   2008/03   2008/05   2008/11   2008/12   2009/01   2009/02   2009/03   2009/04   2009/05   2009/07   2009/09   2009/10   2009/11   2009/12   2010/01  

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]