f



I don't understand why this code isn't working

*** Everything seems to work from here to where my spool file is
created in the *** sql.



# Check for old file - remove if found
if [ -f /var/voice/voicecleanup.txt ]
then
        rm /var/voice/voicecleanup.txt

fi

        # Logon tp SQLplus, Run Sql file
        sqlplus -s username/password<<END
          @build_bulk.sql
          quit
          END
 
 
 **** This is where the code fails. All code after the above line
never executes. What am I doing wrong
          

# Clean up spool file
sed -e 's/^[ \t]*//;s/[ \t]*$//' -e '/^$/d' -e '$d' voicecleanup.lst
>> voicecleanup.txt


          echo '.EOF' >> voicecleanup.txt
0
dafella007
6/9/2004 12:59:28 PM
comp.unix.shell 15484 articles. 3 followers. Post Follow

7 Replies
465 Views

Similar Articles

[PageSpeed] 47


Dafella wrote:

> *** Everything seems to work from here to where my spool file is
> created in the *** sql.
> 
> 
> 
> # Check for old file - remove if found
> if [ -f /var/voice/voicecleanup.txt ]
> then
>         rm /var/voice/voicecleanup.txt

You could just do "rm -f /var/voice/voicecleanup.txt" instead of the 
separate test.

> fi
> 
>         # Logon tp SQLplus, Run Sql file
>         sqlplus -s username/password<<END
>           @build_bulk.sql
>           quit
>           END
>  
>  
>  **** This is where the code fails. All code after the above line
> never executes. What am I doing wrong

You need to put the "END" for the end of the here document at the start 
of the line, or prefix it with a "-" at the start of the here document.
	
	Ed.

0
Ed
6/9/2004 1:42:41 PM
In article <203d44c5.0406090459.1fc1debf@posting.google.com>,
Dafella <dafella007@yahoo.com> wrote:

>         sqlplus -s username/password<<END
>           @build_bulk.sql
>           quit
>           END

Read the shell manpage about '<<'. The terminating 'END' must
match the 'END' after '<<' exactly. The indentation prevents
the match and the rest of the file is consumed by '<<' instead
of being executed.

|        sqlplus -s username/password<<END
|           @build_bulk.sql
|           quit
|END

-- 
G�ran Larsson     http://www.mitt-eget.com/
0
hoh
6/9/2004 1:46:00 PM
On 9 Jun 2004 05:59:28 -0700, Dafella 
  <dafella007@yahoo.com> wrote:
> *** Everything seems to work from here to where my spool file is
> created in the *** sql.
>
>
>         # Logon tp SQLplus, Run Sql file
>         sqlplus -s username/password<<END
>           @build_bulk.sql
>           quit
>           END
>  
>  
>  **** This is where the code fails. All code after the above line
> never executes. What am I doing wrong
>           
Don't indent the END.  Or, if you do indent it, change <<END to <<-END
and use tabs, not spaces.


-- 
Simulations are like miniskirts, they show a lot and hide the essentials.
		-- Hubert Kirrman
0
Bill
6/9/2004 2:13:18 PM
2004-06-09, 08:42(-05), Ed Morton:
> Dafella wrote:
[...]
>> # Check for old file - remove if found
>> if [ -f /var/voice/voicecleanup.txt ]
>> then
>>         rm /var/voice/voicecleanup.txt
>
> You could just do "rm -f /var/voice/voicecleanup.txt" instead of the 
> separate test.

You might end up removing a voicecleanup.txt file that is not a
regular one (or a symlink to a regular file).

-- 
Stephane
0
Stephane
6/9/2004 2:55:03 PM
On Wed, 9 Jun 2004 14:55:03 +0000,
    Stephane CHAZELAS <this.address@is.invalid> wrote:


> 2004-06-09, 08:42(-05), Ed Morton:
>> Dafella wrote:
> [...]
>>> # Check for old file - remove if found
>>> if [ -f /var/voice/voicecleanup.txt ]
>>> then
>>>         rm /var/voice/voicecleanup.txt
>>
>> You could just do "rm -f /var/voice/voicecleanup.txt" instead of the 
>> separate test.
>
> You might end up removing a voicecleanup.txt file that is not a
> regular one (or a symlink to a regular file).
>

test -f symlink will return true if the symlink refers to a regular file.
You need test -h to explicit test for symlink.


Villy
0
Villy
6/9/2004 3:02:04 PM
2004-06-09, 15:02(+00), Villy Kruse:
[...]
>> You might end up removing a voicecleanup.txt file that is not a
>> regular one (or a symlink to a regular file).
>>
>
> test -f symlink will return true if the symlink refers to a regular file.
> You need test -h to explicit test for symlink.

That's what I meant.

rm -f voicecleanup.txt
will remove the voicecleanup.txt if it is neither a regular file
nor a symlink to a regular file.

-- 
Stephane
0
Stephane
6/9/2004 4:08:12 PM
In article <VNedncL0KYJNjlrdRVn-sQ@comcast.com>, Ed Morton wrote:
> 
> 
> Dafella wrote:
> 
>> *** Everything seems to work from here to where my spool file is
>> created in the *** sql.
>> 
>> 
>> 
>> # Check for old file - remove if found
>> if [ -f /var/voice/voicecleanup.txt ]
>> then
>>         rm /var/voice/voicecleanup.txt
> 
> You could just do "rm -f /var/voice/voicecleanup.txt" instead of the 
> separate test.
> 
>> fi
>> 
>>         # Logon tp SQLplus, Run Sql file
>>         sqlplus -s username/password<<END
>>           @build_bulk.sql
>>           quit
>>           END
>>  
>>  
>>  **** This is where the code fails. All code after the above line
>> never executes. What am I doing wrong
> 
> You need to put the "END" for the end of the here document at the start 
> of the line, or prefix it with a "-" at the start of the here document.
> 	

The "-" only works when you use ONLY tabs as whitespace before the EOF. That is
based on both ksh and bash man pages (and my experience)...

Kevin
0
spamtotrash
6/9/2004 9:48:54 PM
Reply: