473,320 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Running Perl Script from within javascript

von
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.

:)
Jul 23 '05 #1
6 5343
von spilled the following:
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.

:)


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.
Jul 23 '05 #2
von
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"
<co**********************@ntlworld.deletemeunlessU RaBot.com> wrote in
message news:tp***************@newsfe5-win.ntli.net...
von spilled the following:
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.

:)


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.

Jul 23 '05 #3

"von" <vo*@vonvon.com> wrote in message
news:N4********************@comcast.com...
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.

:)

XMLHTTPRequest

Jul 23 '05 #4
How much data? If a small amount then

var i=new Image();
i.src="pathtoyourscript.pl?data=" + yourdata;

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

Tim.

"von" <vo*@vonvon.com> wrote in message
news:Z-********************@comcast.com...
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.

:)

Jul 23 '05 #5
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="cTest";
var tOut=null;
var NoResponse="No response";
var sImage=null;

function doIt(sMsg){
delCookie(CookieName);
var sURL="getInfo.asp?v="+escape(sMsg)+"&x="+escape(ne w Date());
sImage=new Image();
sImage.onload=function(){showMsg(true)};
tOut=window.setTimeout("showMsg(false)", ErrorTimeoutSec*1000);
sImage.src=sURL;
}

function delCookie(key){
var d = new Date();
d.setDate(d.getDate() - 2);
document.cookie = key+'=deleted; expires='+d.toGMTString()+';';
}
function showMsg(bOK){
sImage=null;
if(tOut)window.clearTimeout(tOut);
var el=document.getElementById('sAnswer');
if(bOK){
el.innerHTML=getCookie(CookieName);
}else{
el.innerHTML=NoResponse;
}
}
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(document.getElementById('vInput').va lue);return false">
Call</a><br />
<span id='sAnswer'></span>
</BODY>
</HTML>


"von" <vo*@vonvon.com> wrote in message
news:Z-********************@comcast.com...
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.

:)


Jul 23 '05 #6
von
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" <sa************@THISpacbell.net> wrote in message
news:W2*****************@newssvr24.news.prodigy.ne t...
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="cTest";
var tOut=null;
var NoResponse="No response";
var sImage=null;

function doIt(sMsg){
delCookie(CookieName);
var sURL="getInfo.asp?v="+escape(sMsg)+"&x="+escape(ne w Date());
sImage=new Image();
sImage.onload=function(){showMsg(true)};
tOut=window.setTimeout("showMsg(false)", ErrorTimeoutSec*1000);
sImage.src=sURL;
}

function delCookie(key){
var d = new Date();
d.setDate(d.getDate() - 2);
document.cookie = key+'=deleted; expires='+d.toGMTString()+';';
}
function showMsg(bOK){
sImage=null;
if(tOut)window.clearTimeout(tOut);
var el=document.getElementById('sAnswer');
if(bOK){
el.innerHTML=getCookie(CookieName);
}else{
el.innerHTML=NoResponse;
}
}
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(document.getElementById('vInput').va lue);return
false"> Call</a><br />
<span id='sAnswer'></span>
</BODY>
</HTML>


"von" <vo*@vonvon.com> wrote in message
news:Z-********************@comcast.com...
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.

:)



Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tommo | last post by:
Hello All, I am a still learning so be easy on me. I am trying to get some code to work that is using JS and Perl/CGI, I am using AS Perl and an Apache Server on XP as the webserver. Can anyone...
6
by: Richard Trahan | last post by:
I want a js function to call a Perl script residing on a server. The Perl script will return a string, to be used by the js. Pseudo code: <script> stringvar = perlfunc_on_server(stringarg)...
10
by: shumaker | last post by:
I don't need a detailed description of a solution(although I wouldn't mind), but I am hoping someone could tell me in general the best path to go about accomplishing a task, since I don't know all...
2
by: Gemma M | last post by:
Hi, I have a C# program which obtains a string from a database containing VBScript, or JavaScript, or Perl script, and I want C# to be able to run it. In VB6 (COM), I used...
3
by: Nathan Gilbert | last post by:
I am wanting to use javascript to select between different *.css files dependent on the user's browser. I am also wanting to generate the html document containing this javascript dynamically using...
0
by: 123jainmin | last post by:
When I ran a perl script named script.pl which have the the follwing line: system("echo hostname = $HOSTNAME > /tmp/myinfo"); I have another shell script script.ksh which simply call script.pl...
1
by: bpejman | last post by:
Hi Everyone, I've been reading and searching the web for days trying to figure out how exactly you can access and read a Perl array or hash from within JavaScript. I've been reading that JSON is...
12
by: Peter Michaux | last post by:
I'm writing a server-side web application framework using Mozilla's Rhino JavaScript engine. My two primary motivations are so I can write code on server and client sides without needing to switch...
3
by: happyse27 | last post by:
Hi All, I am creating the perl script using html form(with embedded javascript inside). When using this html form with javascript alone, it works where the form validation will pop up...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.