sql server - How to execute multiple commands using Python ssh connection? -


i want execute multiple commands on linux machine after ssh connection it. first command sql command gives sql prompt. second commands sql query

i tried below code doesnt exit out of session.

import paramiko nmsip = "ip" user="user" pwd = "pwd" ssh = paramiko.sshclient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.autoaddpolicy()) ssh.connect(nmsip, 22, username=user, password=pwd) channel = ssh.invoke_shell() stdin = channel.makefile('wb') stdout = channel.makefile('rb')  stdin.write(''' sqlplus  select * *'); exit exit ''')  print stdout.read() 

i have given 2 'exits' exit out of sql , linux session respectively. missing here? there better method achieve this?


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -