1
我试图把这种PERL代码到Python的:到目前为止如何创建一个脚本来执行Python中的执行管理器?
# Create a script on the fly to execute w/ the execution manager
unlink "logger_exit_test.pl";
open my $fh, '>', "logger_exit_test.pl" or die "Unable to create
logger_exit_test.pl";
print {$fh} <<EOF;
#!$EXECUTABLE_NAME
ISC::message(\$ARGV[0], MESSAGE => "test");
EOF
close $fh;
chmod 0750, "logger_exit_test.pl";
,我有这样的Python代码:
## Create a script on the fly to execute w/ the execution manager
try:
os.remove("logger_exit_test.py")
except OSError:
pass
open("logger_exit_test.py", "w+")
with open('logger_exit_test.py') as fh:
for line in fh:
print line
if 'str' in line:
break
executable_name = sys.executable()
ISC.message(sys.argv[0], MESSAGE("test"))
f.close()
os.chmod("logger_exit_test.py", stat.S_IRWXU)
到目前为止,我一直不成功创建可执行...失败:
executable_name = sys.executable()
谢谢,查克!这确实有帮助。 :) –