おはようございます。だから私は仕事のためにこの問題に固執しています。 Paramikoライブラリを使用して、DB2インスタンスの多くの人が仕事で行う簡単な作業を自動化しようとしています。私はすでに1つの仕事をパスワードの束をリセットするように設定していたので、私は、サーバーへの接続の基本が正しいことを知っているので、これらのコマンドの問題は私が欲しいことをしていない。私がしようとしているのは、 "bjobs"の2番目のコマンドの後に出力を表示できるようにしたいということです。私はstdout.read()とこれまでのところ、私に何も与えていないb "'を使ってみました。どんな助けも非常に必要です。パラミコでSASの求人一覧(PYTHON)
from paramiko import client
from os import getlogin
class ssh:
client = None
def __init__(self, address, username, password):
print("Connecting to server")
self.client = client.SSHClient()
self.client.set_missing_host_key_policy(client.AutoAddPolicy())
self.client.connect(address, username=username, password=password)
print("Connected to " + address)
def sendCommand(self, command):
if(self.client):
stdin, stdout, stderr = self.client.exec_command(command)
x= stdout.read()
print(x)
while not stdout.channel.exit_status_ready():
if stdout.channel.recv_ready():
alldata = stdout.channel.recv(1024)
while stdout.channel.recv_ready():
alldata+=stdout.channel.recv(1024)
print(str(alldata, 'utf8'))
else:
print("connection not opened")
serverCon = "My Server"
plist = []
currPass = 'MyPassword!'
#get user information
userName = getlogin()
#Connect to server, insert and chnage passwords
connection = ssh(serverCon, userName, currPass)
connection.sendCommand(r'. /opt/sas/lsf/conf/profile.lsf')
connection.sendCommand('bjobs')
あなたは今あなたをどれだけ愛しているかわかりません。ちょうどSSHを勉強しようとしていますので、私のための少し新しいコンセプトです。あなたが決して少なくなることは決してありません。 – thwalker6
何か問題が見つかったときに、 'stderr.read()'と 'recv_exit_status()'に何が入っているかを見てみることができます。 – pynexj
私はstderr.read()を見てみましたが、私の混乱を招くような値は得られませんでした。私はこれを理解しようとするより多くの時間を私が認めたいと思った以上に過ごしました。 – thwalker6