Subj : run external php script
To : Mortifis
From : echicken
Date : Sat Feb 09 2019 04:23 pm
Re: run external php script
By: Mortifis to All on Sat Feb 09 2019 15:57:26
Mo> my win7_x86 system.
Mo> I tried system.popen("c:\php\php.exe c:\sbbs\myscript.php " + someargs);
Mo> which returns nothing
Per the docs, system.popen does not work on Windows:
http://synchro.net/docs/jsobjs.html#system_methods
There's probably a better way, but this might work:
system.exec('c:\php\php.exe c:\sbbs\myscript.php ' + someargs + ' >c:\poop');
const f = new File('/poop');
f.open('r');
const poop = f.readAll();
f.close();
Now variable 'poop' will be an array of lines of output from your command.
If I were doing a lot of this, I'd probably make a function that:
- Takes the command-line to execute as an argument
- Generates a random tempfile name
- Runs the command and tacks on the redirect to the temp file
- Reads the temp file contents
- Deletes the temp file
- Returns the temp file contents
And then I'd probably still feel a bit gross.
---
echicken
electronic chicken bbs - bbs.electronicchicken.com - 416-425-5435
� Synchronet � electronic chicken bbs - bbs.electronicchicken.com