Wednesday, May 21, 2008

I have a freeboard website and have a trouble with image uploading. When users try to attach an image file- they get a square box with red x in it. Until I change the file permission to 644- they can t see the image. I want a script that will automatically change the file permission to 644 the moment they upload the file- so i don t have to go through every single file to change the permissions. I found something like:

#!/usr/bin/perl
$permissionNum = 0644;
$dirtoopen = "../board/";
opendir (DIR- "$dirtoopen") or die "This is not the correct directory";
@dirdata = readdir(DIR);
closedir (DIR);
$changed = chmod 0644- @dirdata;
print "Content-type: text/html\n\n";
print "$changed files changed to $permissionNum";
BUT!!
1): the file permissions doesn t change to 644- but rather something random. also- 2) this isn t automatic. It s simply useful for changing permissions of bunch of files at once(like 1000 files). Could someone help me with the script. this is urgent!! thx!
By the way I m using windows. I ve been getting infos about how chmod is for linux only? is there a different code for windows?
So is there a specific different function for windows?

Hello-
I am currently running openWrt on wrt54gl router. I have installed full perl (5.8)- and I can run scripts that do no require any modules (other than the base ones- for example- printing "hello world" works just fine). However- when i try to run scripts with "use <module>"- I get error like this-

Can t load /usr/lib/perl/5.8/auto/IO/IO.so for module IO: Unable to resolve symbol at /usr/lib/perl/5.8/XSLoader.pm line 83.
at /usr/lib/perl/5.8/IO.pm line 9
Compilation failed in require at /usr/lib/perl/5.8/IO/Handle.pm line 256.
BEGIN failed--compilation aborted at /usr/lib/perl/5.8.0/IO/Handle.pm line 256.
Compilation failed in require at /usr/lib/perl/5.8.0/IO/Socket.pm line 11.
BEGIN failed--compilation aborted at /usr/lib/perl/5.8.0/IO/Socket.pm line 11.
Compilation failed in require.
BEGIN failed--compilation aborted.

Any one know how to fix it?? thanks
OK so after some investigation- it turned out that it was a kernel problem- and after I updated perl- and recompiled some modules- everything was fine.

Sample Data:
<tocelement name="New classification and
<tocelement name="Gestational diabetes mellitus
<tocelement name="Glycohaemoglobin: a
1997" ca= "ANZ"
<tocelement name="The prevention
<tocelement name="Diabetes and
</tocdivision>

Program:
while (<TEMP1>)
{
$CountTB=substr $_-0-1;
print $CountTB;
if ($CountTB eq "<")
{
print TEMP2 $_;
}
else
{
print "OK";
print "\b"- TEMP2 $_;
}
}

Problem:
I want the " 1997......" to be in 1 line before it. Meaning all lines must first start with "<" since the file is an xml. how am i gonna do it. i have a sample program but everytime i ran it- it stops at the sntence " 1997......" please help????

Correct output i want:
<tocelement name="New classification and
<tocelement name="Gestational diabetes mellitus
<tocelement name="Glycohaemoglobin: a 1997" ca= "ANZ"
<tocelement name="The prevention
<tocelement name="Diabetes and
</tocdivision>

Sample Data:
for date is equal to "99999999".

Question.
Is there a way in perl to store the value between the 2 quotes ("") regardless of how long th value is between them???

Other sample:
"666"
"asdfass"
"asasa343434535345"

I am trying to call a CGI script from the Network Link feature in Google Earth. I can call the script as long as it doesn t contain any parameters. Google Earth throws a parsing error when it sees the "&" in the URL. Is there a special way to invoke the script if it has parameters in Google Earth? Before I converted the Perl Program to CGI- it ran flawlessly. I had a string variable at the top of it that mimmicked the "$ENV{QUERY_STRING}" when it was the regular perl program. I took it out and replaced it with the real thing. I also added the CGI header line saying what type of application it is. ANy ideas?
I tried using the semicolon- and the parsing error didn t show up. However- it then said that it couldn t connect to the server. Any other ideas???

No comments: