Обсуждение: dbt2-shell script problem

Поиск
Список
Период
Сортировка

dbt2-shell script problem

От
Jonas J
Дата:
Hi guys,<br /><br />I get the dbt2 project from the git tree. And i'm trying to make it work with postgres. The problem
isin one of the dbt2 shell scripts. Since I dont understand of Shell Script Programing, here is my problem: (I will
postthe script on the end)<br /><br />1 - I executed:<br />  dbt2-pgsql-load-db -d /tmp/fodao<br />2 - I got the
error:<br/><br />dbt2-pgsql-load-db -d /tmp/fodao<br />[: 77: x: unexpected operator<br />[: 77: no: unexpected
operator<br/>Loading customer table...<br /> COPY customer FROM '/tmp/fodao/.data' WITH NULL AS '';<br />ERROR:  could
notopen file "/tmp/fodao/.data" for reading: No such file or directory<br /><br />3 - I think the correct place should
be'/tmp/fodao/customer.data' instead of "/tmp/fodao/.data"<br /><br />Can anyone help me with this Bash Script ??<br
/><br/>Mant thanks in advace,<br />Jonas<br /><br />--- here comes the scrip:<br />#!/bin/sh<br /><br />#<br /># This
fileis released under the terms of the Artistic License.<br /># Please see # the file LICENSE, included in this
package,for details.<br /> #<br /># Copyright (C) 2002-2008 Mark Wong & Open Source Development Labs, Inc.<br
/>#<br/><br />if [ -z ${DBNAME} ]; then<br />    echo "DBNAME not defined."<br />    exit 1<br />fi<br /><br
/>BACKGROUND="no"<br/><br /> usage()<br />{<br />    echo "usage: `basename $0` -d <dir> [-b] [-l <port>]
[-t]"<br/>    echo "  <dir> is where the data files are."<br />}<br /><br />while getopts "bd:l:t" OPT; do<br />
   case ${OPT} in<br />    b)<br />        BACKGROUND="yes"<br />        ;;<br />    d)<br />       
DBDATA=${OPTARG}<br/>        ;;<br />    l)<br />        PORT=${OPTARG}<br />        ;;<br />    t)<br />       
TABLESPACES_FLAG="-t"<br/>         ;;<br />    esac<br />done<br /><br />if [ "x${DBDATA}" = "x" ]; then<br />   
usage<br/>    exit 1<br />fi<br /><br />if [ ! "x${PORT}" = "x" ]; then<br />    PORTARG="-p ${PORT}"<br /> fi<br /><br
/>#Load tables<br /># This background stuff is honestly kinda ugly. IMO the right way to do this<br /># is to utilize
make-j<br /><br />load_table2() {<br />    $1 "$2" || exit 1<br />    $1 "$3" || exit 1<br /> }<br /><br />load_table()
{<br/>    table=$1<br />    if [ "x$2" == "x" ]; then<br />        file=$table.data<br />    else<br />       
file=$2.data<br/>    fi<br /><br />    local sql="COPY $table FROM '${DBDATA}/$file' WITH NULL AS '';"<br />     local
cmd="psql${PORTARG} -e -d ${DBNAME} -c "<br />    if [ "${BACKGROUND}" == "yes" ]; then<br />        echo "Loading
$tabletable in the background..."<br />        load_table2 "${cmd}" "${sql}" "VACUUM ANALYZE $table;" &<br />    
else<br/>        echo "Loading $table table..."<br />        ${cmd} "${sql}" || exit 1<br />    fi<br />}<br /><br
/>load_tablecustomer<br />load_table district<br />load_table history<br />load_table item<br />load_table new_order<br
/>load_table order_line<br />load_table orders order<br />load_table stock<br />load_table warehouse<br /><br />wait<br
/><br/># load C or pl/pgsql implementation of the stored procedures<br />#if true; then<br /># 
${DIR}/dbt2-pgsql-load-stored-procs-l ${PORT} -t c|| exit 1<br /> #else<br />#  ${DIR}/dbt2-pgsql-load-stored-procs -l
${PORT}-t plpgsql || exit 1<br />#fi<br /><br />exit 0<br /><br /><br /><br /><br /><br /><br /><br /> 

Re: dbt2-shell script problem

От
Robert Haas
Дата:
On Mon, Jan 11, 2010 at 4:18 PM, Jonas J <autoramajj@gmail.com> wrote:
> I get the dbt2 project from the git tree. And i'm trying to make it work
> with postgres. The problem is in one of the dbt2 shell scripts. Since I dont
> understand of Shell Script Programing, here is my problem: (I will post the
> script on the end)

Well this isn't really a "help" list... especially not for
shell-script programming... especially for shell-scripts that aren't
even part of PostgreSQL.

But having said that... I think you must be running a wonky version of sh.

$ DBNAME=rhaas ./broken-script -d /tmp/fodao
Loading customer table...
COPY customer FROM '/tmp/fodao/customer.data' WITH NULL AS '';
ERROR:  relation "customer" does not exist

...Robert


Re: dbt2-shell script problem

От
Jonas J
Дата:
Thanks for your support,<br /><br />The problem was that Ubuntu links /bin/sh to /bin/dash and not /bin/bash, that
makessome scripts crashing. I done the correct linking and everything works fine now.<br />Also thanks for Mark Wong
support,<br/><br />Jonas,<br /><br /><br /><br /><div class="gmail_quote">2010/1/11 Robert Haas <span dir="ltr"><<a
href="mailto:robertmhaas@gmail.com">robertmhaas@gmail.com</a>></span><br/><blockquote class="gmail_quote"
style="border-left:1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On Mon,
Jan11, 2010 at 4:18 PM, Jonas J <<a href="mailto:autoramajj@gmail.com">autoramajj@gmail.com</a>> wrote:<br />
>I get the dbt2 project from the git tree. And i'm trying to make it work<br /> > with postgres. The problem is
inone of the dbt2 shell scripts. Since I dont<br /> > understand of Shell Script Programing, here is my problem: (I
willpost the<br /> > script on the end)<br /><br /></div>Well this isn't really a "help" list... especially not
for<br/> shell-script programming... especially for shell-scripts that aren't<br /> even part of PostgreSQL.<br /><br
/>But having said that... I think you must be running a wonky version of sh.<br /><br /> $ DBNAME=rhaas ./broken-script
-d/tmp/fodao<br /> Loading customer table...<br /> COPY customer FROM '/tmp/fodao/customer.data' WITH NULL AS '';<br />
ERROR: relation "customer" does not exist<br /><br /> ...Robert<br /><font color="#888888"><br /> --<br /> Sent via
pgsql-hackersmailing list (<a href="mailto:pgsql-hackers@postgresql.org">pgsql-hackers@postgresql.org</a>)<br /> To
makechanges to your subscription:<br /><a href="http://www.postgresql.org/mailpref/pgsql-hackers"
target="_blank">http://www.postgresql.org/mailpref/pgsql-hackers</a><br/></font></blockquote></div><br />