这是可能在一个SSH会话? (BASH功放&; PYTHON) [英] Is this possible in one SSH session? (BASH & PYTHON)
问题描述
我正在写一个python脚本(在Linux中),将执行一个SSH并运行远程计算机(太阳OS)上的命令的字符串。我遇到麻烦远程命令来运行,并给予期望的输出,我不知道这甚至有可能。
根据我使用的语法,有时我得到:KSH:28317分段错误(核心转储)
如果这是不可能的,但它是在Python或在命令行使用不同的方法,请让我知道。
谢谢!
SSH用户@ remote_machine/ DVS / DNCS /斌/ tellDhct -h mempoll / mempoll_lowmem_ips.out | awk的'{$打印1}> mempoll / mempoll.macs和放大器;&放; / DVS / DNCS /斌/ tellDhct -h mempoll / mempoll_nonresp_ips.out | awk的'{打印$ 1}'>> mempoll / mempoll.macs
尝试是这样的:
SSH用户@远程<< EOT
回声测试
回声你可以把任何东西在这里就像在bash脚本
回声,它应该工作
EOT
I'm writing a python script (on a Linux box) that will perform an SSH and run a string of commands on the remote machine (Sun-OS). I'm having trouble getting the remote commands to run and give expected output and I'm not sure if this is even possible.
Depending on the syntax I use, sometimes I get : "ksh: 28317 Segmentation Fault(coredump)"
If this is not possible, but it is using a different method in either python or at the CLI, please let me know.
Thanks!
ssh user@remote_machine "/dvs/dncs/bin/tellDhct -h mempoll/mempoll_lowmem_ips.out | awk '{print $1}' > mempoll/mempoll.macs && /dvs/dncs/bin/tellDhct -h mempoll/mempoll_nonresp_ips.out | awk '{print $1}' >> mempoll/mempoll.macs"
Try something like this:
ssh user@remote << EOT
echo "test"
echo "you can put here anything like in a bash script"
echo "and it should work"
EOT
这篇关于这是可能在一个SSH会话? (BASH功放&; PYTHON)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!