[software and hardware technology originating from or otherwise pertinent to planet earth]
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.
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\] \$'
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.
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: 0x0000, bash, code, css, html, javascript, linux, perl, php, script, source, webappdev
Labels: 0x0000, bash, gpg, linux, perl, php, script, shebang shell, SSH, ssh-add, ssh-agent, ssh-copy-id, vnc
#!/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: 0x0000, bash, code, gnu, linux, perl, script, shebang, source
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
Subscribe to Posts [Atom]