我正在从subprocess.run
函数向我的容器化 Hbase DB 运行命令:
subprocess.run(('docker exec hbase bash -c "echo -e create "myTable", "R" | hbase shell"'), shell=True)
该命令似乎按我的预期运行,它打开 HBase shell,然后尝试执行下一个命令但没有撇号:create myTable, R
我得到的错误:
2021-06-01 05:23:18,587 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.2.4, r67779d1a325a4f78a468af3339e73bf075888bac, 2020年 03月 11日 星期三 12:57:39 CST
Took 0.0032 seconds
stty: 'standard input': Inappropriate ioctl for device
create myTable, R
NameError: undefined local variable or method `myTable' for main:Object
myTable
HBase 期望和周围有撇号R
。我尝试运行以撇号为前缀的相同命令:
subprocess.run(('docker exec hbase bash -c "echo -e create \"myTable\", \"R\" | hbase shell"'), shell=True)
但我得到相同的结果。
知道如何防止它删除撇号吗?提前致谢!