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
Post a Comment