Running Perl Script from within javascript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • von

    Running Perl Script from within javascript

    Is it possible to run a Perl script from within a javascript?

    I have an existing javascript that provides some data - and I want to write
    that data to a text file on my server via a Perl script (that I also already
    have).

    Both scripts work great - I just don't know how to make them work together.

    Is this even possible?

    Thanks in advance for all input.

    :)


  • Colin McKinnon

    #2
    Re: Running Perl Script from within javascript

    von spilled the following:
    [color=blue]
    > Is it possible to run a Perl script from within a javascript?
    >
    > I have an existing javascript that provides some data - and I want to
    > write that data to a text file on my server via a Perl script (that I also
    > already have).
    >
    > Both scripts work great - I just don't know how to make them work
    > together.
    >
    > Is this even possible?
    >
    > Thanks in advance for all input.
    >
    > :)[/color]

    Sort of....you can open a window or an iframe from javascript, and you can
    post a form. So you can send parmeters serverside in a GET or load a form
    from the server, populate it then POST it. The latter solution, although
    more laborious, saves a lot of messing around with URL encoding.

    HTH

    C.

    Comment

    • von

      #3
      Re: Running Perl Script from within javascript

      Thanks for your input Colin.

      What I really want to accomplish is to take, say ...

      =============== ====
      'Function Data1 ()'
      {
      [script here];

      }
      =============== ====

      and then send the results of 'Data1' to a text file on my server - all
      without any windows popping up and without requiring any user input.

      :)


      "Colin McKinnon"
      <colin.thisisno tmysurname@ntlw orld.deletemeun lessURaBot.com> wrote in
      message news:tpQPd.559$ D_3.253@newsfe5-win.ntli.net...[color=blue]
      > von spilled the following:
      >[color=green]
      >> Is it possible to run a Perl script from within a javascript?
      >>
      >> I have an existing javascript that provides some data - and I want to
      >> write that data to a text file on my server via a Perl script (that I
      >> also
      >> already have).
      >>
      >> Both scripts work great - I just don't know how to make them work
      >> together.
      >>
      >> Is this even possible?
      >>
      >> Thanks in advance for all input.
      >>
      >> :)[/color]
      >
      > Sort of....you can open a window or an iframe from javascript, and you can
      > post a form. So you can send parmeters serverside in a GET or load a form
      > from the server, populate it then POST it. The latter solution, although
      > more laborious, saves a lot of messing around with URL encoding.
      >
      > HTH
      >
      > C.[/color]


      Comment

      • Mighty  Krell

        #4
        Re: Running Perl Script from within javascript


        "von" <von@vonvon.com > wrote in message
        news:N4CdnVLOz7 UpQZLfRVn-vA@comcast.com. ..[color=blue]
        > Thanks for your input Colin.
        >
        > What I really want to accomplish is to take, say ...
        >
        > =============== ====
        > 'Function Data1 ()'
        > {
        > [script here];
        >
        > }
        > =============== ====
        >
        > and then send the results of 'Data1' to a text file on my server - all
        > without any windows popping up and without requiring any user input.
        >
        > :)
        >
        >[/color]


        XMLHTTPRequest



        Comment

        • Tim Williams

          #5
          Re: Running Perl Script from within javascript

          How much data? If a small amount then

          var i=new Image();
          i.src="pathtoyo urscript.pl?dat a=" + yourdata;

          will work fine. But the HTTPRequest path is more robust....

          Tim.



          "von" <von@vonvon.com > wrote in message
          news:Z-GdnU89WtElUJLfR Vn-1g@comcast.com. ..[color=blue]
          > Is it possible to run a Perl script from within a javascript?
          >
          > I have an existing javascript that provides some data - and I want
          > to write that data to a text file on my server via a Perl script
          > (that I also already have).
          >
          > Both scripts work great - I just don't know how to make them work
          > together.
          >
          > Is this even possible?
          >
          > Thanks in advance for all input.
          >
          > :)
          >[/color]


          Comment

          • Tim Williams

            #6
            Re: Running Perl Script from within javascript

            This is a bit rough but will allow you to send moderate amounts of
            data and get back a status response.

            Tim


            <HTML>
            <HEAD>
            <TITLE>Cookie Remote Scripting</TITLE>

            <SCRIPT type="text/javascript">

            var ErrorTimeoutSec =1.5;
            var CookieName="cTe st";
            var tOut=null;
            var NoResponse="No response";
            var sImage=null;

            function doIt(sMsg){
            delCookie(Cooki eName);
            var sURL="getInfo.a sp?v="+escape(s Msg)+"&x="+esca pe(new Date());
            sImage=new Image();
            sImage.onload=f unction(){showM sg(true)};
            tOut=window.set Timeout("showMs g(false)", ErrorTimeoutSec *1000);
            sImage.src=sURL ;
            }

            function delCookie(key){
            var d = new Date();
            d.setDate(d.get Date() - 2);
            document.cookie = key+'=deleted; expires='+d.toG MTString()+';';
            }


            function showMsg(bOK){
            sImage=null;
            if(tOut)window. clearTimeout(tO ut);
            var el=document.get ElementById('sA nswer');
            if(bOK){
            el.innerHTML=ge tCookie(CookieN ame);
            }else{
            el.innerHTML=No Response;
            }
            }


            function getCookie(sName ) {

            var dc = document.cookie ;
            var arrC=dc.split(" ;");
            var tc;
            var retVal="No value"

            for(x=0;x<arrC. length;x++){
            tc=arrC[x].split("=");
            tc[0]=tc[0].replace(" ","")
            if(tc[0]==sName)retVal = unescape(tc[1]);
            }

            return retVal;
            }

            </SCRIPT>
            </HEAD>
            <BODY>
            <input type="text" size=20 id='vInput' value="blah">
            <A href="#"
            onclick="doIt(d ocument.getElem entById('vInput ').value);retur n false">
            Call</a><br />
            <span id='sAnswer'></span>
            </BODY>
            </HTML>



            [color=blue]
            >
            > "von" <von@vonvon.com > wrote in message
            > news:Z-GdnU89WtElUJLfR Vn-1g@comcast.com. ..[color=green]
            >> Is it possible to run a Perl script from within a javascript?
            >>
            >> I have an existing javascript that provides some data - and I want
            >> to write that data to a text file on my server via a Perl script
            >> (that I also already have).
            >>
            >> Both scripts work great - I just don't know how to make them work
            >> together.
            >>
            >> Is this even possible?
            >>
            >> Thanks in advance for all input.
            >>
            >> :)
            >>[/color]
            >
            >[/color]


            Comment

            • von

              #7
              Re: Running Perl Script from within javascript

              Thanks Tim.

              I sent you an email.

              What I am actually doing is generating a small amount of data via the
              Javascript - for example an IP address (though that is not it) and then I
              want to send that piece of information to a log - that can be viewed via a
              URL.

              The script works great when outputting this info to the screen - but I want
              it sent to a file to store.

              I don't really want it writing back to the screen so the response is not
              necessary. I also want this completely invisible to the user.

              Thanks for all your input Tim. :)


              -Von


              "Tim Williams" <saxifraxREMOVE @THISpacbell.ne t> wrote in message
              news:W2TPd.3870 $lz5.2898@newss vr24.news.prodi gy.net...[color=blue]
              > This is a bit rough but will allow you to send moderate amounts of data
              > and get back a status response.
              >
              > Tim
              >
              >
              > <HTML>
              > <HEAD>
              > <TITLE>Cookie Remote Scripting</TITLE>
              >
              > <SCRIPT type="text/javascript">
              >
              > var ErrorTimeoutSec =1.5;
              > var CookieName="cTe st";
              > var tOut=null;
              > var NoResponse="No response";
              > var sImage=null;
              >
              > function doIt(sMsg){
              > delCookie(Cooki eName);
              > var sURL="getInfo.a sp?v="+escape(s Msg)+"&x="+esca pe(new Date());
              > sImage=new Image();
              > sImage.onload=f unction(){showM sg(true)};
              > tOut=window.set Timeout("showMs g(false)", ErrorTimeoutSec *1000);
              > sImage.src=sURL ;
              > }
              >
              > function delCookie(key){
              > var d = new Date();
              > d.setDate(d.get Date() - 2);
              > document.cookie = key+'=deleted; expires='+d.toG MTString()+';';
              > }
              >
              >
              > function showMsg(bOK){
              > sImage=null;
              > if(tOut)window. clearTimeout(tO ut);
              > var el=document.get ElementById('sA nswer');
              > if(bOK){
              > el.innerHTML=ge tCookie(CookieN ame);
              > }else{
              > el.innerHTML=No Response;
              > }
              > }
              >
              >
              > function getCookie(sName ) {
              >
              > var dc = document.cookie ;
              > var arrC=dc.split(" ;");
              > var tc;
              > var retVal="No value"
              >
              > for(x=0;x<arrC. length;x++){
              > tc=arrC[x].split("=");
              > tc[0]=tc[0].replace(" ","")
              > if(tc[0]==sName)retVal = unescape(tc[1]);
              > }
              >
              > return retVal;
              > }
              >
              > </SCRIPT>
              > </HEAD>
              > <BODY>
              > <input type="text" size=20 id='vInput' value="blah">
              > <A href="#" onclick="doIt(d ocument.getElem entById('vInput ').value);retur n
              > false"> Call</a><br />
              > <span id='sAnswer'></span>
              > </BODY>
              > </HTML>
              >
              >
              >
              >[color=green]
              >>
              >> "von" <von@vonvon.com > wrote in message
              >> news:Z-GdnU89WtElUJLfR Vn-1g@comcast.com. ..[color=darkred]
              >>> Is it possible to run a Perl script from within a javascript?
              >>>
              >>> I have an existing javascript that provides some data - and I want to
              >>> write that data to a text file on my server via a Perl script (that I
              >>> also already have).
              >>>
              >>> Both scripts work great - I just don't know how to make them work
              >>> together.
              >>>
              >>> Is this even possible?
              >>>
              >>> Thanks in advance for all input.
              >>>
              >>> :)
              >>>[/color]
              >>
              >>[/color]
              >
              >[/color]


              Comment

              Working...