We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4643
    • 34 Posts
    Hi Forum!

    Would be very grateful if someone could point me in the right direction regarding how to execute scripts.

    I’ve tried to call a Perl script in a form (action="myscript.pl") and it works fine if I save the file physically in the old fashioned way on the server but if I create a MODx document with an alias "myscript.pl" and save it using no template (blank), the entire text of the perl code is printed - not executed.

    Here’s the simple test script I’m using:
    -----
    #!/usr/bin/perl
    print "Content-type: text/html\n\n";
    print "Message text here\n";
    -----

    I’ve tried different document types (text/javascript, text/html, text/plain) but no luck. I’ve also tried to save the script as a snippet but then I can’t figure out how to call it (and execute it) in the "form action" statement (I tried both: form action="[[snippet]]" and form action=[[snippet]] but that doesn’t seem to be the way to do it.

    Is there another way of doing it? I suppose I can always upload the "real" perl files to the server but it would be neater to have them in MODx somehow - as documents, chunks or snippets but I don’t really understand how to get them executed.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      http://il.php.net/passthru

      You should be able to call the passthru() function from a snippet and then return whatever your perl script returns to the php script as usual.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 4643
        • 34 Posts
        Hi,
        Thank you very much for that tip, I’ll try that when I get some time over soon. I’ve settled for the "physical" perl files for now but I would like to remove them and make it all database driven, that would feel much "neater".

        Appreciate the fast help in this forum! You’re good!