Sqlplus login error when using bash variables: SP2-0306: Invalid option

前端 未结 4 1541
星月不相逢
星月不相逢 2020-12-11 21:00

I have a bash script that connects to an oracle 10g database.

In a first step it takes some variables from a \"config\" file with the following command



        
相关标签:
4条回答
  • 2020-12-11 21:35

    I solved this problem on my mac machine by changing the shell to 'sh' from 'bash'. Everything just worked smooth then.

    Thanks to the original reporter of the problem who explained with a good hint.

    0 讨论(0)
  • 2020-12-11 21:36

    This worked for me: connect user/"password" I think if the password contains special characters like '@' we need to use "" for the password.

    0 讨论(0)
  • 2020-12-11 21:41

    Daft question, but are you sure you are using the bash shell on both unix servers ?

    I'd try replacing

    export USR_PASS="$USRID/$USRID_PASS@myDatabase"
    

    with export USR_PASS="${USRID}/${USRID_PASS}@myDatabase"

    to make sure the variables get interpreted correctly

    As a final, exotic though, does the password contain any characters other than basic alpha-numeric and punctuation. Because 10g isn't case sensitive, a lowercase password gets converted to uppercase, which can cause odd effects with things like accented characters

    0 讨论(0)
  • 2020-12-11 21:47

    The message is pretty clear:

    • you've successfully contacted a database
    • the credentials supplied are wrong

    This indicates there isn't really anything wrong with your client configuration.

    So, that leaves you with

    • the user/pw combination is wrong
    • you've not contacted the database you think you have

    Possibilites:

    • Make sure you can connect with the credentials supplied from the command line.
    • Use tnsping mydatabase to check the host and instance you're contacting, verify it's correct. Output from this command should tell you the host, port, and instance/service you're connecting to. If it's wrong, check the tnsnames.ora file for this alias.
    • As @OMG Ponies suggests, if you're using 11g, make sure the case in your passwords is correct
    0 讨论(0)
提交回复
热议问题