分享
这是一个创建于 的主题,其中的信息可能已经有所发展或是发生改变。
如题,报错提示:
<main.oscheck instance at 0x7f54694ae560>
代码:
```
import os
class oscheck:
'操作系统检查'
cmdoutput = 0
def __init__(self, oscmd, outfile):
self.oscmd = oscmd
self.output = outfile
print('self.oscmd:' + oscmd)
print('self.output:' + self.output)
def runcmd(self):
cmdResault = os.popen(self.oscmd)
oscheck.cmdoutput = cmdResault.read()
print('cmdoutput' + oscheck.cmdoutput)
def printoutfile(self):
global cmdoutput
with open(self.output, 'w') as file:
file.write(str(cmdoutput))
print ('日志文件更新内容 : ' + cmdoutput.read())
op1 = oscheck('ls /tmp','/tmp/op1.log')
print(op1)
op2 = oscheck('df -h','/tmp/op2.log')
print(op2)
op1.runcmd
op1.printoutfile
op2.runcmd
op2.printoutfile
```
执行结果:
```
[test@test_2025 backup]$ python znsql_tool.py
self.oscmd:ls /tmp
self.output:/tmp/op1.log
<__main__.oscheck instance at 0x7f29ddd91560>
self.oscmd:df -h
self.output:/tmp/op2.log
<__main__.oscheck instance at 0x7f29ddd915a8>
```
麻烦帮忙指导下,感谢感谢。
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信1637 次点击
添加一条新回复
(您需要 后才能回复 没有账号 ?)
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传