如题,报错提示:
<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>
```
麻烦帮忙指导下,感谢感谢。
有疑问加站长微信联系(非本文作者)