• run external php script

    From Mortifis@VERT/ALLEYCAT to All on Sat Feb 9 10:57:00 2019
    I am trying to get a php script to run externally from an sbbs.ssjs script, I have this working on my Linux system but am having problems on my win7_x86 system.

    I tried system.popen("c:\php\php.exe c:\sbbs\myscript.php " + someargs);
    which returns nothing

    so I tried system.exec("c:\php\php.exe c:\sbbs\myscript.php " + someargs); which returns 1

    So, my question is, how do I trap the result under windows, it is handled automagically under Linux

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81
  • From echicken@VERT/ECBBS to Mortifis on Sat Feb 9 11:23:00 2019
    Re: run external php script
    By: Mortifis to All on Sat Feb 09 2019 15:57:26

    my win7_x86 system.

    I tried system.popen("c:\php\php.exe c:\sbbs\myscript.php " + someargs); 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
  • From Mortifis@VERT/ALLEYCAT to echicken on Sat Feb 9 13:02:00 2019
    Re: run external php script
    By: Mortifis to All on Sat Feb 09 2019 15:57:26

    my win7_x86 system.


    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.

    perhaps a shower afterward would help :-)

    Thanks for the info, now I gotta p, open a beer

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81
  • From Digital Man@VERT to Mortifis on Sat Feb 9 11:17:00 2019
    Re: run external php script
    By: Mortifis to All on Sat Feb 09 2019 03:57 pm

    I am trying to get a php script to run externally from an sbbs.ssjs script, I have this working on my Linux system but am having problems on my win7_x86 system.

    I tried system.popen("c:\php\php.exe c:\sbbs\myscript.php " + someargs); which returns nothing

    system.popen() only works on *nix-like OSes (not Windows).

    so I tried system.exec("c:\php\php.exe c:\sbbs\myscript.php " + someargs); which returns 1

    Is that literally what you tried, or did you double-up those backslashes, as would be necessary in a JavaScript string?

    So, my question is, how do I trap the result under windows, it is handled automagically under Linux

    system.exec() will just run the command. If you want the output of the command, you'll need to redirect the output to a file and read that file (on Windows).

    digital man

    Synchronet "Real Fact" #88:
    SBBSecho v3.00 was first committed to cvs.synchro.net on Apr-11-2016.
    Norco, CA WX: 55.3F, 60.0% humidity, 2 mph NW wind, 0.09 inches rain/24hrs

    ---
    Synchronet Vertrauen Home of Synchronet [vert/cvs/bbs].synchro.net
  • From wkitty42@VERT/SESTAR to Mortifis on Sun Feb 10 05:56:00 2019
    Re: run external php script
    By: Mortifis to All on Sat Feb 09 2019 15:57:26

    So, my question is, how do I trap the result under windows, it
    is handled automagically under Linux

    we just went through this with tickit... we were trying to determine why addfiles was not working right for someone when tickit ran as an event but it (addfiles) did run properly when they manually ran tickit...

    look at the tickit sources in the addfiles section and you'll see what i came up with that worked great and was left in tickit if anyone needed the facility later for troubleshooting...


    )/\(aldo

    ---
    Synchronet SouthEast Star Mail HUB - SESTAR
  • From Mortifis@VERT/ALLEYCAT to Digital Man on Sun Feb 10 07:26:00 2019
    Re: run external php script
    By: Mortifis to All on Sat Feb 09 2019 03:57 pm


    system.exec() will just run the command. If you want the output of the command, you'll need to redirect the output to a file and read that file (on Windows).


    No wonder I dislike windows LOL

    Is there an equivelent to file_get_content('http://blah_blah.blah');
    I was poking around some sources and found http_request.header but it didn't work.

    I am just trying to include a little url data in index.ssjs

    ie: template.myvar = whatever_grabs_the_url_contents('http://the.url/' + any_args);

    so I can simply use @@myvar@@ in any web docs. ( I have done this on Linux without issue using system.popen

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81
  • From Mortifis@VERT/ALLEYCAT to Digital Man on Sun Feb 10 07:29:00 2019
    Re: run external php script
    By: Mortifis to All on Sat Feb 09 2019 03:57 pm


    system.exec() will just run the command. If you want the output of the command, you'll need to redirect the output to a file and read that file (on Windows).


    No wonder I dislike windows LOL

    Is there an equivalent to file_get_content('http://blah_blah.blah');
    I was poking around some sources and found http_request.header but it didn't work.

    I am just trying to include a little url data in index.ssjs

    ie: template.myvar = whatever_grabs_the_url_contents('http://the.url/' + any_args);

    so I can simply use @@myvar@@ in any web docs. ( I have done this on Linux without issue using system.popen

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81
  • From echicken@VERT/ECBBS to Mortifis on Sun Feb 10 07:07:00 2019
    Re: Re: run external php script
    By: Mortifis to Digital Man on Sun Feb 10 2019 12:29:40

    Is there an equivalent to file_get_content('http://blah_blah.blah');

    require('http.js', 'HTTPRequest');
    const response = (new HTTPRequest()).Get('http://blah_blah.blah');

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-425-5435
    Synchronet electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to echicken on Sun Feb 10 11:37:00 2019
    Re: Re: run external php script
    By: Mortifis to Digital Man on Sun Feb 10 2019 12:29:40

    Is there an equivalent to file_get_content('http://blah_blah.blah');

    require('http.js', 'HTTPRequest');
    const response = (new HTTPRequest()).Get('http://blah_blah.blah');

    Thank you, I am getting closer, just gotta scrape some css stuffs in the response.

    BTW where do I find your openweathermap.js? I looked on github under web4but seem to have lost my glasses :-o

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81
  • From echicken@VERT/ECBBS to Mortifis on Sun Feb 10 11:15:00 2019
    Re: Re: run external php script
    By: Mortifis to echicken on Sun Feb 10 2019 16:37:16

    BTW where do I find your openweathermap.js? I looked on github under web4but seem to have lost my glasses :-o

    It's a generic library and not part of the web interface. I put it in the Synchronet CVS under exec/load/. Note that the script doesn't do anything on its own to display information to a BBS user; it's a library for scripts that want to interact with the OWM API.

    I did create a sidebar module for the web interface that uses this library; it's under web/sidebar/.extras/ in the github repo.

    OpenWeatherMap use requires an API key, so you'll have to go to their site and sign up for one. Add a section to ctrl/modopts.ini like this:

    [openweathermap]
    api_key=your_api_key_here

    The library is designed to cache data and respect the rate limits imposed on OWM free-tier accounts by default.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com - 416-425-5435
    Synchronet electronic chicken bbs - bbs.electronicchicken.com
  • From Mortifis@VERT/ALLEYCAT to wkitty42 on Sun Feb 10 12:12:00 2019
    Re: run external php script
    By: Mortifis to All on Sat Feb 09 2019 15:57:26

    So, my question is, how do I trap the result under windows, it
    is handled automagically under Linux

    we just went through this with tickit... we were trying to determine why addfiles was not working right for someone when tickit ran as an event but it (addfiles) did run properly when they manually ran tickit...

    look at the tickit sources in the addfiles section and you'll see what i came up with that worked great and was left in tickit if anyone needed the facility later for troubleshooting...

    I did, thank you, knew how to redirect to files and read them, seems a long way around that mr gates imposed upon us :- hopefully some future verion of winbloz has a comparable > /dev/null 2>&1 function or whatever ... I only bothered with all this cuz I broke a G string on my acoustic and got bored LOL

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81
  • From Mortifis@VERT/ALLEYCAT to echicken on Sun Feb 10 14:16:00 2019
    Re: Re: run external php script
    By: Mortifis to echicken on Sun Feb 10 2019 16:37:16

    BTW where do I find your openweathermap.js? I looked on github under web4but seem to have lost my glasses :-o

    It's a generic library and not part of the web interface. I put it in the Synchronet CVS under exec/load/. Note that the script doesn't do anything on its own to display information to a BBS user; it's a library for scripts that want to interact with the OWM API.

    which is what I want to play with :-)

    I did create a sidebar module for the web interface that uses this library; it's under web/sidebar/.extras/ in the github repo.

    I was looking in web/sidebar/.extras/openwethermap.ssjs and saw the reference to openweathermap.js but couldn't find it either on my system or in github. I'll grab it from cvs.synchro.net, thanks


    OpenWeatherMap use requires an API key, so you'll have to go to their site and sign up for one. Add a section to ctrl/modopts.ini like this:



    I have had an openweathermap key for a couple years that I use with my php scripts, I still use Duece's old runemaster nightshade, but I will look into the webv4, thanks :)

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81
  • From Mortifis@VERT/ALLEYCAT to echicken on Sun Feb 10 14:22:00 2019
    Re: Re: run external php script
    By: Mortifis to echicken on Sun Feb 10 2019 16:37:16

    BTW where do I find your openweathermap.js? I looked on github under web4but seem to have lost my glasses :-o

    It's a generic library and not part of the web interface. I put it in the Synchronet CVS under exec/load/. Note that the script doesn't do anything on its own to display information to a BBS user; it's a library for scripts that want to interact with the OWM API.


    BTW I have been working on incorporating the wttr.in python scripts or curl calls
    into the web/nightshade templates. I have used both openweathermaps and wttr.in for sometime on some of my other sites under LAMP using both <iframe> and file_get_contents, just playing around. I will look closely at the .js ... I appreciate the help, thanks.

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81
  • From Rampage@VERT/SESTAR to Mortifis on Thu Feb 14 08:17:00 2019
    Re: Re: run external php script
    By: Mortifis to wkitty42 on Sun Feb 10 2019 17:12:24

    look at the tickit sources in the addfiles section and you'll
    see what i came up with that worked great and was left in
    tickit if anyone needed the facility later for
    troubleshooting...

    I did, thank you, knew how to redirect to files and read them,
    seems a long way around that mr gates imposed upon us :-
    hopefully some future verion of winbloz has a
    comparable > /dev/null 2>&1 function or whatever ...

    well, it does but it is slightly different ;)

    I only bothered with all this cuz I broke a G string on my
    acoustic and got bored LOL

    i think i'd rather play with the G string as long as the female that owns it is close by and willing to play a "round or two" O:) -=B-)


    )\/(ark

    ---
    Synchronet SouthEast Star Mail HUB - SESTAR
  • From Mortifis@VERT/ALLEYCAT to Rampage on Thu Feb 14 10:13:00 2019

    I only bothered with all this cuz I broke a G string on my
    acoustic and got bored LOL

    i think i'd rather play with the G string as long as the female that owns it is close by and willing to play a "round or two" O:) -=B-)


    that might work for you but they know what I look like so they'd likely play the E eeeeee...... & leave me B eeeeee ... strings and run away :-P



    2 wrongs don't make a right, but 3 left turns will get you back on the freeway!

    ---
    Synchronet AlleyCat! BBS - http://alleycat.synchro.net:81