import os
#print(os.system('ls'))
#print(os.system('pwd'))
for i in range(1000):
cmd = input('[test@foundation0 bin]$')
if cmd:
if cmd == 'exit':
print('logout')
break
else:
print('run %s' %(cmd))
# 运行shell命令
os.system(cmd)
else:
continue
本文介绍了一个使用Python编写的简单交互式Shell脚本,该脚本允许用户输入命令并在本地环境中执行,提供了类似终端的体验。脚本通过os模块执行用户输入的命令,但为了安全考虑,实际代码中并未真正运行命令。
276

被折叠的 条评论
为什么被折叠?



