【发布时间】:2021-12-20 08:30:45
【问题描述】:
我尝试使用 PYTHON 通过 ssh 发送 cqlsh 命令并不断收到类似的错误
-
输入 ':' 没有可行的替代方案
-
dsecqlsh.py 端口无效
...
我搜索了包括堆栈溢出在内的互联网,没有给出答案。
def sshRemoteCmd(user,host,cmd):
import subprocess
import re
x = subprocess.Popen("ssh {user}@{host} {cmd}".format(user=user, host=host, cmd=cmd), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
result=''
if not x:
result = 'error'
else:
for item in x:
result += item.decode('ascii')
return result
cmd = f'''cqlsh -e "select * from MYTABLE where userid='12345';"'''
print(cmd)
result = sshRemoteCmd('root','hosts', cmd)
print(result)
【问题讨论】: