Skip to main content
Known Participant
April 18, 2007
Answered

Load variables from a perl script

  • April 18, 2007
  • 12 replies
  • 581 views
Basically I want to load the date of the server from a Perl script to my Flash. However it looks like the onLoad function doesn't load successfully; it always goes to the else condition. I've tried to put the Perl script & the SWF file in the same/different directory. What i am doing wrong here? Please see the scripts below:

**********************************************************
var externalData:LoadVars = new LoadVars();

externalData.onLoad = function(success:Boolean):Void{
if(success) {
theDate.text = externalData.serverDate;
} else {
theDate.text = "";
}
}
externalData.load("theDate.pl");
***************************************************************
theDate.pl

#!/usr/local/bin/perl

my $cYr = (localtime)[5]+1900;
my $cMth = (localtime)[4]+1;
my $cDay = (localtime)[3];

my $today = "$cMth/$cDay/$cYr";

print "&serverDate=", $today, "\n";
************************************************************

Thanks in advance
This topic has been closed for replies.
Correct answer kglad
i don't know coldfusion so i'm not able to help you with that. i can tell you the problem is not with the actionscript and i can help with the perl script.

when you sent an email outside the cgi-bin directory was that a perl file, too? if yes and your perl path was the same in the email file (#!/usr/local/bin/perl), then add:

print "Content-type: text/html\n\n";

just after your perl path in your date file and retest.

12 replies

kglad
Community Expert
Community Expert
April 18, 2007
great.
lvbaoAuthor
Known Participant
April 18, 2007
Thank you kglad for your fast respond. Everything is working now.
Inspiring
April 18, 2007
>>theDate.text = my_lv.serverDate;

Are you getting success true now? If so then I always use a form like this,
instead of what you have:

theDate.text = this['serverDate'];



--
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 18, 2007
i don't know coldfusion so i'm not able to help you with that. i can tell you the problem is not with the actionscript and i can help with the perl script.

when you sent an email outside the cgi-bin directory was that a perl file, too? if yes and your perl path was the same in the email file (#!/usr/local/bin/perl), then add:

print "Content-type: text/html\n\n";

just after your perl path in your date file and retest.
lvbaoAuthor
Known Participant
April 18, 2007
I am kind of frustrated here :). Yes, everything works when I use a text file. However when I use a server side script, it's not working. Browsers I am testing are FireFox V2.0.0.3 and IE V7.

Just now I try to test on another server using ColdFusion, it gives me undefined value. Again if I use text file, it works fine.

**********************************************
theDate.cfm

<cfset myDate = dateFormat(now(), 'mm/dd/yyyy')>
<cfoutput>serverDate=#myDate#</cfoutput>
*******************************************************
theDate.txt

&serverDate=04/18/2007
*******************************************************
SWF file

var my_lv:LoadVars = new LoadVars();

my_lv.onLoad = function(success:Boolean):Void {
if(success) {
theDate.text = my_lv.serverDate;
} else {
theDate.text = "";
}
}
my_lv.load("theDate.cfm");
kglad
Community Expert
Community Expert
April 18, 2007
the cache is on your computer, not on the server. you can clear that using your browser settings if that's causing confusion. what browser/version are you using?

so, everything works when you use a text file but not when you use perl?
kglad
Community Expert
Community Expert
April 18, 2007
what was in your text file and what code was in your swf?
lvbaoAuthor
Known Participant
April 18, 2007
I am sorry, it shows the date with the text file. However with the same SWF I put it in the perl script, it's not working so I think it's cache in the server?
lvbaoAuthor
Known Participant
April 18, 2007
Yes, I have a cgi-bin directory but the web host doesn't require perl scripts to be in there (i think so because I tried to send an email outside the cgi-bin and it works fine.)

I also tried to load the date from a text file in the same directory but it doesn't work either. Why?
kglad
Community Expert
Community Expert
April 18, 2007
do you have a cgi-bin (or cgi) directory? if so, does your web host require perl scripts to be in that directory?
lvbaoAuthor
Known Participant
April 18, 2007
no it's not in the cgi-bin directory. It's in the same directory with the SWF. Also I did 'chmod 755 theDate.pl'.