Re: shell script help
Posted in 1999
Topics: Storage & Space Management, Server Administration
See my answer inline the code below.
"Art S. Kagel" escribis:
>
> Add a semi-colon to the end of line 11.
>
> Also you may want to get Jonathan Leffler's sqlcmd which can be started
> in server mode outside the loop and reads from a FIFO which will be
> written to by sqlcmd in client mode. This saves great chunks of time
> and will make your script more responsive as only the server process
> actually connects to the database while the client only writes the
> commands to the FIFO for processing by the server. In this way your
> script users will not have to wait while dbaccess connects to the
> server and opens the database just for one insert. FWIW.
>
> Art S. Kagel
I agree
>
> carina@371.net wrote:
> >
> > I wrote a small shell script(insert.sh) to insert record to a table
> > (named mytable). mytable has 3 char type columns : name,birth,addr.
> > mydb is the database name.
> >
> > insert.sh
> > ******************************************
> > 1 flag=1
> > 2 while test $flag==1
> > 3 do
> > 4 echo type in name:
> > 5 read name
> > 6 echo type in birth:
> > 7 read birth
> > 8 echo type in addr:
> > 9 read addr
> > 10 dbaccess $1 << EOF
> > 11 INSERT INTO mytable
> > 12 VALUES($name,$birth,$addr)
This line should say:
VALUES("$name","$birth","$addr");
because the syntax for char/date variables in informix when you set
values from constants. Remember that the shell translates $name, $birth
and $addr into their content WITHOUT delimiters of any kind. The blanks
included into $name, the slashes in $birth and blanks in $addr, cause a
syntax error.
> > 13 EOF
> > 14 echo continue(y/n)?
> > 15 read answer
> > 16 if $answer=='y'
> > 17 then flag=1
> > 18 else flag=0
> > 19 fi
> > 20 done
> > *****************************************
> >
> > $ insert.sh mydb> > insert.sh: syntax error at line 21: `end of file' unexpected
> >
> > Any hints and opinior will be appreciated!
> >
> > Sent via Deja.com http://www.deja.com/
> > Share what you know. Learn what you don't.
--
Mario R. Canto
mcanto@intec.unl.edu.ar
mcanto@intec.arcride.edu.ar
http://www.intec.unl.edu.ar/~mcanto