Thread: Multiple atributes with -P switch to psql
Hi all, Trying to get psql to produce multiple table attributes in the <table> tag when psql is used with the -H switch. eg TABLEOPTIONS="-P border=5 -P tableattr=width=\"80%\"" psql $DATABASEHOST -U $DATABASEUSER -d $DATABASE -q -P footer -P title=Summary -H $TABLEOPTIONS produces ... <table border="5" width="80%"> ... As expected. TABLEOPTIONS="-P border=5 -P tableattr=width=\"80%\" -P tableattr=bgcolor=\"#FFFFFF\"" produces ... <table border="5" bgcolor="#FFFFFF"> ... Seems to hang on to the last. And TABLEOPTIONS="-P border=5 -P tableattr=\"width=\"80%\" bgcolor=\"#FFFFFF\"\"" produces ... <table border="5" "width="80%"> ... My quoting of the quotes is wrong but the point is that the quote to encapsulate the white space for the tablattr is placedinto the HTML produced. It maybe that you can only pass one table attribute or that I'm missing something. I favour the latter. Calls are from within a bash script. Can anyone set me straight? version ------------------------------------------------------------------------------------- PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.3 (SuSE Linux) (1 row) Thanks Allan The material contained in this email may be confidential, privileged or copyrighted. If you are not the intended recipient,use, disclosure or copying of this information is prohibited. If you have received this document in error, pleaseadvise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses containedin this email or any attachments.
Hi Allan, > TABLEOPTIONS="-P border=5 -P tableattr=width=\"80%\" -P tableattr=bgcolor=\"#FFFFFF\"" > produces ... > <table border="5" bgcolor="#FFFFFF"> ... > Seems to hang on to the last. Yes- you've said -P tableattr twice so the second one overrides the first one. $ psql -H -P tableattr='width="80%" bgcolor="#FFFFFF"' works for me. Carefully study my nice simple quoting: single quotes '' around the whole tableattr='THING' shebang and non-escaped double quotes "" for width and bgcolor values. Cheers, Stuart.
Stuart, Thanks for the reply. You are dead right, and as expected the problem is not with psql. > $ psql -H -P tableattr='width="80%" bgcolor="#FFFFFF"' > > works for me. Carefully study my nice simple quoting: single quotes '' > around the whole > tableattr='THING' shebang and non-escaped double quotes "" for width > and bgcolor values. > > Cheers, > Stuart. > In my defence I did try that exact quoting, the problem is that it is being run from a script. I have thrown together anexample to show the problem. I have not yet worked to a solution. If you know what it is I would be very greatful. Allan #!/bin/bash set -x DATABASEHOST="-h jitsnwm" DATABASEUSER=galvuser DATABASE=galvdb TABLEOPTIONS="-P border=5 -P tableattr='width=\"80%\" bgcolor=\"#AFAFAF\"'" ED=/usr/local/pgsql/bin $ED/psql $DATABASEHOST -U $DATABASEUSER -d $DATABASE -q -P footer -P title=Summar y -H $TABLEOPTIONS <<EOF_SQL select version(); EOF_SQL Produces.... postgres@jitsnwm:~/agl/sql> ./z.sh + DATABASEHOST=-h jitsnwm + DATABASEUSER=galvuser + DATABASE=galvdb + TABLEOPTIONS=-P border=5 -P tableattr='width="80%" bgcolor="#AFAFAF"' + ED=/usr/local/pgsql/bin + /usr/local/pgsql/bin/psql -h jitsnwm -U galvuser -d galvdb -q -P footer -P title=Summary -H -P border=5 -P 'tableattr='\''width="80%"''bgcolor="#AFAFAF"'\''' <table border="5" 'width="80%"> <caption>Summary</caption> <tr> <th align="center">version</th> </tr> <tr valign="top"> <td align="left">PostgreSQL 8.2.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.3 (SuSE Linux)</td> </tr> </table> The material contained in this email may be confidential, privileged or copyrighted. If you are not the intended recipient,use, disclosure or copying of this information is prohibited. If you have received this document in error, pleaseadvise the sender and delete the document. Neither OneSteel nor the sender accept responsibility for any viruses containedin this email or any attachments.