首页 \ 问答 \ 从网页运行PHP CLI脚本(Run a PHP CLI script from a webpage)

从网页运行PHP CLI脚本(Run a PHP CLI script from a webpage)

我有一个(可能是愚蠢的)问题。 我有一个PHP脚本,用于cli使用。 当我从命令行运行它时工作正常,没有问题。 问题是我正在使用的网站对主机服务器有ssh限制,我无法在那里运行ssh。 因此我的问题是:我如何从另一个可以通过网络访问的php运行脚本? 已经尝试使用exec(),system()等。主要问题是我需要他$ _SERVER ['SHELL']变量集,并且当调用来自web浏览器当然php不会设置它。

任何ideeas将大大优于,thanx。


I have a (possibly dumb) question. I have a script made in php, constructed for cli usage. Works fine when I run it from the command line, no problem there. The problem is that the site I'm working on has ssh restrictions on the hosting server and I cannot ssh there to run it. Hence my question: how can I run the script from another php that is web-accessible? Already tried with exec(), system(), etc. The main problem is that I need he $_SERVER['SHELL'] variable set, and when the call is comming from a web browser of course php doesn't set it.

Any ideeas will be greatly apreciated, thanx.


原文:https://stackoverflow.com/questions/4969250
更新时间:2023-04-05 11:04

最满意答案

这里是Stroustrup的介绍: C ++风格和技术常见问题

在C ++中, NULL的定义是0,所以只有一个审美的差异。 我更喜欢避免宏,所以我使用0.另一个NULL问题是人们有时错误地认为它不同于0和/或不是一个整数。 在标准前的代码中, NULL有时被定义为不合适的东西,因此必须/必须避免。 这几天并不常见。

如果你必须命名空指针,调用它为nullptr ; 这就是C ++ 11中所说的。 那么, nullptr将是一个关键字。

也就是说,不要出现小东西。


Here's Stroustrup's take on this: C++ Style and Technique FAQ

In C++, the definition of NULL is 0, so there is only an aesthetic difference. I prefer to avoid macros, so I use 0. Another problem with NULL is that people sometimes mistakenly believe that it is different from 0 and/or not an integer. In pre-standard code, NULL was/is sometimes defined to something unsuitable and therefore had/has to be avoided. That's less common these days.

If you have to name the null pointer, call it nullptr; that's what it's called in C++11. Then, nullptr will be a keyword.

That said, don't sweat the small stuff.

相关问答

更多
  • 常数0的解释取决于上下文。 如果它在需要数字的上下文中使用,则为零。 如果它在需要指针的上下文中使用,则将其视为空指针。 所以如果你有代码: int n = 0; // assigns zero int *p = 0; // assigns null pointer somefunc((char *)0); // passes null pointer to the function 在C中,允许宏NULL扩展为整数常量0或这样的常量强制转换为void * 。 在C ++ pre-11中,它可以扩展为一个 ...
  • 根据我的经验, if (ptr)或if (!ptr)形式的测试是首选的。 它们不依赖于符号NULL的定义。 他们不会暴露意外任务的机会。 他们清晰简洁。 编辑:由于SoapBox在注释中指出,它们与C ++类(例如auto_ptr兼容,它们是作为指针的对象,它们提供了一个转换为bool来完全实现这个习语。 对于这些对象,与NULL的显式比较将不得不调用对指针的转换,这可能具有其他语义副作用,或者比bool转换意味着的简单存在检查更昂贵。 我喜欢代码,说明没有不需要的文字是什么意思。 if (ptr != N ...
  • 回到C ++ 03,空指针由ISO规范(§4.10/ 1)定义为 空指针常量是计算为零的整数类型的积分常量表达式(5.19)rvalue。 这就是为什么在C ++中你可以写 int* ptr = 0; 在C中,这个规则是相似的,但有点不同(§6.3.2.3/ 3): 值为0的整数常量表达式,或者转换为void *类型的表达式称为空指针常量.5)如果将空指针常量转换为指针类型,则生成的指针(称为空指针)为保证比较不等于指向任何对象或函数的指针。 因此,两者 int* ptr = 0; 和 int* ptr ...
  • 这里是Stroustrup的介绍: C ++风格和技术常见问题 在C ++中, NULL的定义是0,所以只有一个审美的差异。 我更喜欢避免宏,所以我使用0.另一个NULL问题是人们有时错误地认为它不同于0和/或不是一个整数。 在标准前的代码中, NULL有时被定义为不合适的东西,因此必须/必须避免。 这几天并不常见。 如果你必须命名空指针,调用它为nullptr ; 这就是C ++ 11中所说的。 那么, nullptr将是一个关键字。 也就是说,不要出现小东西。 Here's Stroustrup's t ...
  • 当在c ++中传递一个指针(即foo(some_object* p) )时,你实际上传递了指针的值,即对象所在的位置。 值本身是一个副本,这意味着如果你做p = NULL; 在你的函数里面,它不会改变原来的指针,但是它指向的地址保存了同一个原始对象。 例: #include using namespace std; class obj{ public: int a; }; void foo(obj* pp){ pp->a = 2; pp = NULL; ...
  • 对于指针, p和(p != 0)完全相同。 如果它给你一个段错误,那么它不是一个简单的指针,或者问题在其他地方 For a pointer, p and (p != 0) are exactly equivalent. If it gives you a segfault, then either it's not a plain pointer, or the problem is elsewhere
  • 这是不好的做法,原因如下: 在析构函数中将指针设置为null可能会掩盖双重破坏问题。 良好的做法是尽早发现问题。 在delete指针之前检查指针是否只会增加不必要的代码。 delete通过什么都不做来处理空指针。 好的做法是尽量减少代码量。 This is bad practice for the following reasons: Setting a pointer to null in the destructor may mask double destruction problem. Good p ...
  • 通过说int *ptr = NULL; 你说的是“我正在声明一个名为ptr的int指针,我想指向位置0 ( NULL )。这就是它所说的。 现在,如果您尝试读取或写入ptr您将得到未定义的行为 ,这通常是一个可怕的地方(比仅仅得到错误更糟糕,因为您的程序可能开始在其他地方遇到问题而您不知道为什么) 。 但通常,当您想要表示不应该使用NULL指针并且必须初始化时,会使用NULL指针。 正如大卫施瓦茨所说, 如果使用int* ptr而不是int *ptr ,将更容易理解。 这是因为ptr的类型实际上是int* ...
  • 以下是将其设置为NULL - 将其定义为不同的类型: LookupTable* table = NULL; 如果您习惯于处理C#,那么您可能会将类视为“值类型”。 这也可能与您的想法不同。 在C ++中: LookupTable table1; LookupTable table2 = table; 编辑table2时,table1不会更改。 和: void SomeFunction(LookupTable t) { ...
  • 在C ++ 03中,比ptr = NULL更喜欢ptr = 0 (Bjarne S.说,阅读下面引自他的网站的摘录) 在C ++ 0x中, ptr = nullptr (请参阅此 ) Bjarne Stroustrup说 , 我应该使用NULL还是0? 在C ++中,NULL的定义是0,所以只存在美学差异。 我宁愿避免使用宏,所以我使用0. NULL的另一个问题是人们有时会错误地认为它不同于0和/或不是整数。 在预标准代码中,NULL有时被定义为不适合的东西,因此必须避免。 这些日子不太常见。 如果您必须命 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)