php-cli用于系统管理员? [英] php-cli for system admin?

查看:62
本文介绍了php-cli用于系统管理员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真的,php-cli对系统管理任务有用吗?


我怀疑php-cli是否会匹配perl或python,对于系统管理员来说

脚本语言。但是,php-cli是否足够接近sys

这些语言的管理能力,这些语言可能实际上对于

管理员有用?


据我所知,没有人认真使用php来编写shell脚本

语言。那是因为perl如此成熟吗?或者因为

php没有力量?


我还没有找到很多关于使用php进行系统管理,或者

使用php-cli。我用Google搜索,但我发现的只有你好

世界。类型示例。

解决方案

真的,php-cli对系统管理任务有用吗?


理论上是的,但在实践中...


我怀疑php-cli是否会匹配perl或python,对于系统管理员来说

脚本语言。但是,php-cli是否足够接近sys /

这些语言的管理能力,这些语言可能实际上对于

管理员有用?



我担心一切都取决于操作系统,当然还有你想要做的事情。


据我所知,没有人认真使用php作为shell脚本

语言。那是因为perl如此成熟吗?或者因为

php没有力量?



我*做了*尝试。有些事情应该在Web服务器上完成

使用脚本,并且PHP是保证在开发机器和服务器上保证存在的唯一语言

网站必须运行

on。 PHP往往是非常特定于操作系统的,所以我想在PHP中完成至少一些

的测试脚本。有一些缺点:


- 除非您专门调用语言

解释器,否则不会传递参数。所以testdir.php somedir不会看到somedir

参数,但是C:\PHP \ php.exe testdir.php somedir将。我认为一个

系统管理员能够在linux下解决这个问题,但我不知道如何。


- 运行Windows时,创建的目录是只读的。我不得不将
shell输出到dos只是为了以有用的方式创建一个目录。当然,

所有操作系统独立性都停在这里。在linux下,你可以给出创建

标志,但是在windows中会忽略这些标志。


...,但我找到的只是你好世界类型示例。



嗯,这样可行,但其余的可能需要更多的测试,我很害怕.B $ b。害怕。


最好的问候


Dikkie Dik写道:


>真的,php-cli对系统管理任务有用吗?



理论上是的,但在实践中......



实际上,是的。我在PHP中做了很多CLI脚本,它们工作得非常好。


>我怀疑php-cli将匹配perl或python,用于sys管理员脚本语言。但是,php-cli是否足够接近那些php可能对
管理员有用的语言的管理能力?



我担心一切都取决于操作系统,当然还有你想做的事情。



我发现我可以在PHP中做任何我可以用其他语言做的事情。

有没有你发现用PHP在Perl中你不能做的事情

或Python?


>据我所知,没有人认真使用php进行shell脚本编写
语言。那是因为perl如此成熟吗?或者因为
php没有力量?



我*做了*尝试。有些事情应该在Web服务器上完成

使用脚本,并且PHP是保证在开发机器和服务器上保证存在的唯一语言

网站必须运行

on。 PHP往往是非常特定于操作系统的,所以我想在PHP中完成至少一些

的测试脚本。有一些缺点:



很多人使用PHP作为shell脚本语言。


- 除非您专门调用语言

解释器,否则不传递参数。所以testdir.php somedir不会看到somedir

参数,但是C:\PHP \ php.exe testdir.php somedir将。我认为一个

系统管理员能够在linux下解决这个问题,但我不知道怎么做。



我不知道在Windows上(我没有设置文件关联

自动运行它们),但它们在Linux上。如果他们不在您的系统上,那么您的系统就会崩溃。


- 运行Windows时,创建的目录是只读的。我不得不将
shell输出到dos只是为了以有用的方式创建一个目录。当然,

所有操作系统独立性都停在这里。在linux下,你可以给出创建

标志,但是这些标志在windows中被忽略。



正如我所说 - 我不是在Windows上执行它们。


> ...,但我找到的只是hello world。类型示例。



嗯,这样可行,但其余的可能需要更多的测试,我很害怕.B
害怕。
< br $>
最好的问候



但是我还没有在Windows上做Perl或Python脚本。


-

==================

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================


别忘了,PHP实际上不仅仅基于网络和基于cli ...

但是基于GTK2;)所以不仅yopu可以使用shell脚本来管理

系统...但你可以用

php做一个非常好用且有帮助的视觉应用......


其实我使用PHP shell脚本来执行远程管理

任务...如 http: // myhomeserver / scriptsfolder / thisaction ...

之一,备份eve3rything(Postgresql,Mysql,webroot)如果需要

醒来一个服务...它会备份并再次关闭它...

然后scp我文件...到我目前正在使用的电脑...(通常是

我的笔记本电脑或房子桌面)


还...我已经制作的Webapps的设置....我通常会创建一个lil

设置为em ...所以,如果我卖掉它,并且客户端不需要大的修改......我只是...解压缩,运行......脚本执行

休息: p $ / $
相信我..你甚至可以在Linux上创建一个带有php的文件下载器,例如15

分钟... ... xD


For real, could php-cli be useful for system admin tasks?

I doubt php-cli will ever match perl, or python, for a sys admin
scripting language. But, does php-cli come close enough to the sys
admin power of those languages that php might actually be useful for
admins?

As far as I know, nobody seriously uses php for a shell scripting
language. Is that just because perl is so well established? Or because
php doesn''t have the power?

I have not been able to find much about using php for system admin, or
using php-cli at all. I googled around, but all I find were "hello
world" type examples.

解决方案

For real, could php-cli be useful for system admin tasks?

Theoretically yes, but in practise...

I doubt php-cli will ever match perl, or python, for a sys admin
scripting language. But, does php-cli come close enough to the sys
admin power of those languages that php might actually be useful for
admins?

I am afraid that all depends on the OS and off course what you want to do.

As far as I know, nobody seriously uses php for a shell scripting
language. Is that just because perl is so well established? Or because
php doesn''t have the power?

I *did* try it. There are things that should be done on a web server
with scripts, and PHP is the only language that is guaranteed to exist
on both the development machine and the servers the site has to be run
on. And PHP tends to be pretty OS-inspecific, so I wanted at least some
testscripts done in PHP. There are a few drawbacks:

- Parameters are not passed, unless you specifically call the language
interpreter. so "testdir.php somedir" will not see the somedir
parameter, but "C:\PHP\php.exe testdir.php somedir" will. I think a
sysadmin was able to fix this under linux, but I do not know how.

- When running windows, created directories are read-only. I had to
shell out to dos just to create a directory in a useful way. Off course,
all OS-independence stops here. Under linux, you can give the create
flags, but these are ignored in windows.

..., but all I find were "hello world" type examples.

Well, that will work, but the rest may requires som more testing, I''m
afraid.

Best regards


Dikkie Dik wrote:

>For real, could php-cli be useful for system admin tasks?


Theoretically yes, but in practise...

In practice, yes. I do a lot of CLI scripts in PHP and they work quite
well.

>I doubt php-cli will ever match perl, or python, for a sys admin
scripting language. But, does php-cli come close enough to the sys
admin power of those languages that php might actually be useful for
admins?


I am afraid that all depends on the OS and off course what you want to do.

I find I can do anything in PHP that I can do in the other languages.
Is there something you''ve found you can''t do in PHP that you can in Perl
or Python?

>As far as I know, nobody seriously uses php for a shell scripting
language. Is that just because perl is so well established? Or because
php doesn''t have the power?


I *did* try it. There are things that should be done on a web server
with scripts, and PHP is the only language that is guaranteed to exist
on both the development machine and the servers the site has to be run
on. And PHP tends to be pretty OS-inspecific, so I wanted at least some
testscripts done in PHP. There are a few drawbacks:

A lot of people use PHP for a shell scripting language.

- Parameters are not passed, unless you specifically call the language
interpreter. so "testdir.php somedir" will not see the somedir
parameter, but "C:\PHP\php.exe testdir.php somedir" will. I think a
sysadmin was able to fix this under linux, but I do not know how.

I don''t know about on Windows (I don''t have the file associations set up
to run them automatically), but they are on Linux. If they aren''t on
your system, your system is broken.

- When running windows, created directories are read-only. I had to
shell out to dos just to create a directory in a useful way. Off course,
all OS-independence stops here. Under linux, you can give the create
flags, but these are ignored in windows.

As I said - I don''t do them on Windows.

>..., but all I find were "hello world" type examples.


Well, that will work, but the rest may requires som more testing, I''m
afraid.

Best regards

But then I also don''t do Perl or Python scripts on Windows.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


Dont forget, that PHP actually is not only web-based and cli based...
but GTK2 based ;) so not only yopu can use shell scripts to admin the
system... but you can do a pretty nice and helpfull visual app with
php...

actually i use PHP shell scripting to do remote administrative
tasks... like http://myhomeserver/scriptsfolder/thisaction... one of
them, backs up eve3rything (Postgresql, Mysql, webroot) if it needs to
wake up a service... it will do it backup and shut it down again...
and then scp me the files... to the pc i am currently on... (Usually
my laptop, or the house desktop)

also... setups for Webapps that i''ve made.... i usually create a lil
setup for em... so if i sold it, and the client doesnt needs big
modifications... i just... unpack, run... and the script does the
rest :p
belive me.. you can even create a filedownloader with php in like 15
mins... on linux... xD


这篇关于php-cli用于系统管理员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆