Re: Simple Unix script..but goes awry

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 05/19/04


Date: Wed, 19 May 2004 02:02:55 -0400

In article <621f2639.0405181907.1eefe86@posting.google.com>,
 benjose@hotmail.com (BenJose) wrote:

> Hi!
>
> Here is a simple Unix script that I used to insert the contents of a
> log file into an Oracle db.
>
> #!/bin/sh
> FILE1=tst.txt
> echo $FILE1
> rm tmp.sql
> $MSG=`cat $FILE1`
> echo $MSG
> echo "insert into DLY_MSGS values(SYSDATE,'"$MSG"'); \n commit; \n q
> uit;">tmp.sql
> cat tmp.sql
> /export/apps/oracli/mplus/9.2.0/bin/sqlplus debdwc/debdwc@DOEBODS1
> @tmp.sql
> ~
> ~
>
> Now the 'cat' command does'nt just get the contents of the file, but
> also goes into an infinite loop doing a 'ls' on the current
> directory... Any pointers... or any suggestions...

Are you sure it's not the "echo" command that's doing that? Does
changing it to:

echo "$MSG"

fix it? If so, I'll bet that tst.txt contains globbing characters.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


Relevant Pages

  • Re: findstr, for, or other command to do this?
    ... I have a log file with many fields and lines. ... > construct a command or batch file that will return a unique list of computer ... echo %%I>> tmp.$$$ ... I saw this in a movie about a bus that had to SPEED around a city, keeping its SPEED over fifty, and if its SPEED dropped, it would explode. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Order of command execution in backquotes
    ... The command inside backquotes is executed and its output is saved. ... If the backquoted command is not inside double quotes, word splitting and wildcard processing is performed on the result, and this replaces the result. ... echo `cat testfile.txt` ... echo "`cat testfile.txt`" ...
    (comp.unix.shell)
  • Re: Network Copy Changing File Name to Something Unique (ex date a
    ... Comments and File Name to a log file I have in the store ... >>I cannot figure out how to make the copy command accept a variable for ... Until the echo is ... > The pause alloes you to revise the output. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Order of command execution in backquotes
    ... The command inside backquotes is executed and its output is saved ... If the backquoted command is not inside double quotes, ... echo `cat testfile.txt` ... echo "`cat testfile.txt`" ...
    (comp.unix.shell)
  • Re: Difference between cat and echo
    ... When I get my emails, for the cat command, the subject states: ... However for the echo command I get "echo " in the subject but the body ... but only cat reads from standard input. ...
    (Fedora)