0

i would like to ask a very simple question, i have a script which will connect to oracle database for some activities

If i executed the scriptfrom PUTTY, it able to connect to database BUT if i execute the script in Python using paramiko client, it cant connect to database.

I guess it's environment issue but i'm not quite sure. Please give your opinion.

Below is the exact command i use in putty.

cd tes1/test2/runtime/; ./test.init.start

And this is what I try in Python with Paramiko:

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('<Hostname>', username='<username>', password='<password>')

stdin, stdout, stderr = client.exec_command('cd tes1/test2/runtime/; ./test.init.start')

UPDATE:

ERROR MESSAGE=
?WCSERV-F-Error during connect to data base
?SQ-F-connect to database failed 
ORA-12162: TNS:net service name is incorrectly specified

LATEST UPDATE: Hi i solved this and i figured this might help others, so the reason was the environment path messed up as im using paramiko, tried many ways but only 1 work which is running the script explicitly via login shell for example : bash --login -c "ls", goodluck!

kichik
  • 33,220
  • 7
  • 94
  • 114
Old G
  • 366
  • 1
  • 4
  • 9
  • Please share the error message. – Thomas Aug 14 '19 at 07:31
  • Already, just added – Old G Aug 14 '19 at 07:34
  • To clarify, is this an issue with the actual connection with the database (line 3 trace) or to do with running the script? If it's the latter, it seems like an Oracle question. – Thomas Aug 14 '19 at 07:37
  • I don't think it's oracle issue because it works well if i executed the script in Putty, just when i executed using paramiko in python, i will get the error message – Old G Aug 14 '19 at 07:41
  • `ORA-12162` is an Oracle error code. I'm not too familiar with Oracle, but a Google search tells me you might need to set a `ORACLE_SID` environment variable. All in all, I don't know if there's enough information to answer the question. – Thomas Aug 14 '19 at 07:45
  • This [link](https://stackoverflow.com/a/49496127/11633985) might help. – Thomas Aug 14 '19 at 07:47
  • Tried to include ORACLE_SID in the command but seems like no effect – Old G Aug 14 '19 at 08:18
  • hi guys, i've solved the issue and editted the question above on the the solution – Old G Aug 21 '19 at 06:41

0 Answers0