# shell script exiting before completing

**URL:** <https://community.unix.com/t/shell-script-exiting-before-completing/243837>\
**Category:** Shell Programming and Scripting\
**Created:** [July 2, 2009, 10:00am UTC](https://community.unix.com/t/shell-script-exiting-before-completing/243837 "2009-07-02T10:00:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![welldone](https://community.unix.com/letter_avatar/welldone/32/6_22734026db12803ebb3e059622ac3534.png) [@welldone](https://community.unix.com/u/welldone)\
**Post date:** [July 2, 2009, 10:00am UTC](https://community.unix.com/t/shell-script-exiting-before-completing/243837/1 "2009-07-02T10:00:43Z")

</div>

I have a script which has the following statement,

/opt/oracle/product/9i/bin/sqlplus \<\< EOC \>\> $LOG\_FILE 2\>&1  
username/password ---- Enters the SQL prompt  
@/export/home/oracle/shells/grant\_userview.sql ---Runs the SQL script  
@/export/home/oracle/shells/grant\_proc\_userview.sql ---Runs the SQL script  
@/export/home/oracle/shells/createindex.sql ---Runs the SQL script  
exit --- Exits the SQL prompt  
EOC

imp system/password file=/oradata/temp/user.dmp fromuser=user 1 touser=user2 indexes=y log=user.log -- Runs on $ prompt.

The statement in red above doesnt run. When run out of the script manually it succeeds, I am trying to figure if i have to move this "exit" below the last line, Please advice

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/6_22734026db12803ebb3e059622ac3534.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [July 2, 2009, 10:13am UTC](https://community.unix.com/t/shell-script-exiting-before-completing/243837/2 "2009-07-02T10:13:25Z")

</div>

Does it produce an error?

(and what is the 1 between the fromuser and touser part)?

```nohighlight
fromuser=user 1 touser=user2

```

Just as a thought: Is that imp command you show exactly the command you run from the script, or is the username/password, for example, in a variable? If so, did you export the varaible?

The exit isn't neccessary either in the SQL\*Plus or the script. You should replace it with a / in the SQL.

---

<div class="post-metadata">

**Author:** ![fpmurphy](https://community.unix.com/user_avatar/community.unix.com/fpmurphy/32/110_2.png) [@fpmurphy](https://community.unix.com/u/fpmurphy)\
**Post date:** [July 2, 2009, 10:15am UTC](https://community.unix.com/t/shell-script-exiting-before-completing/243837/3 "2009-07-02T10:15:14Z")

</div>

What happens if you add the full pathname to imp?

---

<div class="post-metadata">

**Author:** ![welldone](https://community.unix.com/letter_avatar/welldone/32/6_22734026db12803ebb3e059622ac3534.png) [@welldone](https://community.unix.com/u/welldone)\
**Post date:** [July 2, 2009, 2:33pm UTC](https://community.unix.com/t/shell-script-exiting-before-completing/243837/4 "2009-07-02T14:33:13Z")

</div>

Hi Scottn/fpmurhpy,

No there is no export of username/password required in the script because it contains the original username and password.

This script was running and since couple of days it terminates and doesnt run that imp command.

Thanks.

---

<div class="post-metadata">

**Author:** ![Scott](https://community.unix.com/letter_avatar/scott/32/6_22734026db12803ebb3e059622ac3534.png) [@Scott](https://community.unix.com/u/Scott)\
**Post date:** [July 2, 2009, 2:36pm UTC](https://community.unix.com/t/shell-script-exiting-before-completing/243837/5 "2009-07-02T14:36:24Z")

</div>

What does user.log say?

Remove the exit anyway, as it's not required.

---

<div class="post-metadata">

**Author:** ![vidyadhar85](https://community.unix.com/user_avatar/community.unix.com/vidyadhar85/32/997_2.png) [@vidyadhar85](https://community.unix.com/u/vidyadhar85)\
**Post date:** [July 2, 2009, 2:39pm UTC](https://community.unix.com/t/shell-script-exiting-before-completing/243837/6 "2009-07-02T14:39:16Z")

</div>

file=/oradata/temp/user.dmp  
is this file available in that location..

---

<div class="post-metadata">

**Author:** ![radoulov](https://community.unix.com/user_avatar/community.unix.com/radoulov/32/489_2.png) [@radoulov](https://community.unix.com/u/radoulov)\
**Post date:** [July 2, 2009, 2:56pm UTC](https://community.unix.com/t/shell-script-exiting-before-completing/243837/7 "2009-07-02T14:56:34Z")

</div>

> [@welldone](#):
>
> [...]  
> This script was running and since couple of days it terminates and doesnt run that imp command.

If you enable tracing, you should be able to see what happens.
