kshsua

SUA-Korn shell not retaining environment variables


I am using SUA-Korn shell on Windows where in I have set an alias in .profile as alias sqlplus='sqlplus.exe'

So when I start SUA-Korn shell and run sqlplus it calls sqlplus.exe and works fine but when I put same command in .ksh file and run it gives error that 'unknown command sqlplus'

Below is .ksh file

#!/bin/ksh
sqlplus main/main@SID9 @script.sql

If I execute above test.ksh in SUA-Korn shell as

. test.ksh 

then it works fine but

test.ksh

gives

unknown command sqlplus.

Thanks In Advance


Solution

  • Unfortunately, aliases only work in interactive shells. I would suggest using a function or a variable instead. Both of these will translate to your shell script.

    In your .profile:

    sqlplus="sqlplus.exe"
    

    In your script:

    eval $sqlplus main/main@SID9 @script.sql
    

    Give that a shot.