如何使每个人都可以从任何地方执行 Perl 脚本?
我编写了一个非常简单的 Perl 脚本,现在我想让它从任何地方都可执行。
我知道我可以将其放入 /bin/ 中,将其从“mytest.pl”重命名 -> 'mytest' 和 chmod +x,但这是标准做法吗? 我注意到 /bin/ 中没有任何内容是 perl 脚本。
另外,我希望它能够登录到 /var/logs/mytest/*
是否有我应该注意的安全问题?
I wrote a very simple perl script, and now I want to make it executable from everywhere.
I know I could just drop it into /bin/, rename it from 'mytest.pl' -> 'mytest', and chmod +x, but is this standard practice? I noticed nothing in /bin/ is a perl script.
Also, I want it to be able to log to /var/logs/mytest/*
Are there any security issues I should be aware of?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好将用户编写的脚本放在 /usr/local/bin 中,但是否值得担心这一点取决于您。 至于登录到 /var/logs/mytest/* ,您可以尝试使脚本 suid (出于安全考虑,有时不允许这样做)与可以写入该目录的用户,或者只是使 /var/logs/mytest 全局可写。
It is preferable to put user-made scripts in /usr/local/bin , but it's your call whether it's worth worrying about this. As far as logging to /var/logs/mytest/*, you can try to make the script suid (this is sometimes not allowed for security) with a user that can write to the dir, or just make /var/logs/mytest world-writable.
与其担心日志文件权限问题,为什么不记录到系统记录器呢? 这就是它的用途。 请参阅 Sys::Syslog
Instead of worrying about log file permissions issues, why not log to the system logger? That's what it's there for. See Sys::Syslog