我不习惯使用 Linux,但我想尝试在 Linux vps 上使用 slimerjs,以便访问 php exec 功能,因为大多数托管公司禁用该功能。
我确实成功安装了 xampp、vsftpd、xulrunner、xvfb 和 slimerjs(独立版本)。
当我运行以下命令时,会启动 slimerjs,但仅调用 console.log 函数:
xvfb-run ./slimerjs hello.js
我尝试在开始时添加 sudo 但结果是一样的。
这是上述命令的“响应”:
Hi
6 XSELINUXs still allocated at reset
SCREEN: 0 objects of 132 bytes = 0 total bytes 0 private allocs
DEVICE: 0 objects of 64 bytes = 0 total bytes 0 private allocs
CLIENT: 0 objects of 112 bytes = 0 total bytes 0 private allocs
WINDOW: 0 objects of 20 bytes = 0 total bytes 0 private allocs
PIXMAP: 2 objects of 8 bytes = 16 total bytes 0 private allocs
GC: 4 objects of 8 bytes = 32 total bytes 0 private allocs
CURSOR: 0 objects of 4 bytes = 0 total bytes 0 private allocs
DBE_WINDOW: 0 objects of 12 bytes = 0 total bytes 0 private allocs
TOTAL: 6 objects, 48 bytes, 0 allocs
2 PIXMAPs still allocated at reset
PIXMAP: 2 objects of 8 bytes = 16 total bytes 0 private allocs
GC: 4 objects of 8 bytes = 32 total bytes 0 private allocs
CURSOR: 0 objects of 4 bytes = 0 total bytes 0 private allocs
DBE_WINDOW: 0 objects of 12 bytes = 0 total bytes 0 private allocs
TOTAL: 6 objects, 48 bytes, 0 allocs
4 GCs still allocated at reset
GC: 4 objects of 8 bytes = 32 total bytes 0 private allocs
CURSOR: 0 objects of 4 bytes = 0 total bytes 0 private allocs
DBE_WINDOW: 0 objects of 12 bytes = 0 total bytes 0 private allocs
TOTAL: 4 objects, 32 bytes, 0 allocs
./slimerjs: line 172: 4568 Aborted "$SLIMERJSLAUNCHER" -app $SLIMERDIR/application.ini $PROFILE -no-remote "$@" 2> /dev/null
/usr/bin/xvfb-run: line 171: kill: (4558) - No such process
这是hello.js的内容
console.log("Hi");
var page = require("webpage").create();
console.log("Hi");
page.open("http://www.youtube.com/")
.then(function(status){
console.log("Hi");
if (status == "success") {
console.log("The title of the page is: "+ page.title);
}
else {
console.log("Sorry, the page is not loaded");
}
page.close();
setTimeout(function(){phantom.exit();},5000);
});
仅执行第一个console.log。如果我在开头添加 10 个连续的 console.log,它们都会被执行。下面的代码不执行该setTimeout
函数:
console.log("Hi");
setTimeout(function(){console.log("Hi");});
总结一下:如果在执行代码时发现了除 console.log 之外的其他内容,它将在那里停止。
在尝试 slimerjs 之前,我尝试了 phantomjs,效果非常好!我不知道 slimerjs 有什么问题。也许是因为我想用 xvfb 执行它?
答案1
我也得到了:
./slimerjs: line 172: 4568 Aborted "$SLIMERJSLAUNCHER" -app $SLIMERDIR/application.ini $PROFILE -no-remote "$@" 2> /dev/null
直到我想起要跑export SLIMERJSLAUNCHER=/usr/bin/firefox
。
请注意,您需要安装 Firefox。