English 中文(简体)
• 如何从仅靠面包机打入“Sand”的手套?
原标题:how to call php script from just server by bash?
  • 时间:2011-08-10 06:48:36
  •  标签:
  • php
  • bash

i 每天要执行一个文件箱。 i 带以下线的印本。 并且正用这一文字。 但是,可以通过这种方式从另一台计算机中执行。 更不用说网络服务器名称=“slmnbr”。

x http://slmnbr/myscript.php。

i 只需要服务器。

BASE_URL=http://`get-webservername`
/usr/bin/wget --no-check-certificate --timeout=0 -O - "$BASE_URL/myscript.php"

预先感谢

最佳回答

You need to have PHP CLI (command line interface) to do this. It often comes with the PHP installation package (or a separate package).

因此,正如“James”提到,你需要先用CLI PHP可执行的名称,在窗户上php.exe,在您的安装名录中有些地方。

在UN*X系统中,该编码在<代码>/usr/bin或/usr/ local/bin/opt/ local/bin上有些地方。 如果是在太平洋沿岸地区,你就可以简单地执行:

php your_script.php

但铭记,从服务器上操作你的文字与从网络服务器上操作不一样。 例如,您获得的t有POST/code>或GET变量。 因此,你的文字可能不会奏效。

您可以通过以下方式使手工艺品的用户无法读取,使网上服务器无法读到这些书,而用户则通过http://usually www-data管理。

I recommend to make it readable only by the user who is running it from cron:

chown cronuser your_script.php
chmod 0400 your_script.php

Update2

If you re running your script in cron with the same user as the webserver does, then at the top of your script stop it from being executed:

if (!(php_sapi_name() ==  cli  && empty($_SERVER[ REMOTE_ADDR ]))) {
  header( HTTP/1.1 403 Forbidden );
  exit;
}
问题回答

To execute a task(or a php script) every day use cron.

这一联系具有你所需要的一切动力,包括防止外部接触。

With any recent version of "php" you should get a standalone executable called: "php.exe"

Just execute this like so:

/usr/local/php.exe your_script.php




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...