nsForum logo

Welcome Guest ( Log In )

 
Reply to this topicStart new topic
> Perl Open File "permission Denied", perl open file "permission denied"
kyboy
post Sep 4 2008, 01:26 PM
Post #1





Group: Verified NS Member
Posts: 155
Joined: 31-August 08
From: ky
Member No.: 2,243



open (LOG, ">log.txt");

Gets permission denied.

The above should overwrite the file.
I even tried pre-creating the file and FTP'ing it to the same folder
the perl script is running.

The folder this resides in has rwx rwx rwx privileges (per netsol file manager).
log.txt has rw rw rw privileges.

My hosting plan is Windows Basic.

I've tried to find info on the netsol site, and here on the netsol forums
and googled the web in general.

What am I missing?
Go to the top of the page
 
+Quote Post
ddavis
post Sep 4 2008, 01:39 PM
Post #2





Group: Verified NS Member
Posts: 2,287
Joined: 10-August 07
Member No.: 6



QUOTE (kyboy @ Sep 4 2008, 01:44 PM) *
open (LOG, ">log.txt");

Gets permission denied.

The above should overwrite the file.
I even tried pre-creating the file and FTP'ing it to the same folder
the perl script is running.

The folder this resides in has rwx rwx rwx privileges (per netsol file manager).
log.txt has rw rw rw privileges.

My hosting plan is Windows Basic.

I've tried to find info on the netsol site, and here on the netsol forums
and googled the web in general.

What am I missing?

Try single quotes instead of double around the logfile
Go to the top of the page
 
+Quote Post
kyboy
post Sep 4 2008, 02:09 PM
Post #3





Group: Verified NS Member
Posts: 155
Joined: 31-August 08
From: ky
Member No.: 2,243



Thanks for the reply, but that didn't help.

Here's the whole script...

print "Content-type: text/html \n\n";
open (OUT1,">out1.txt");
print "Couldn't open output file (<font color=red>$!</font>), so I'm bugging out.<br>\n";
print OUT1 "testing 123 \n";
close (OUT1);
exit;


I've tried about every combination I can think on the open statement, spaces, no spaces, parends, no parends, etc. The file doesn't show up in the folder.

Note, I have no path as the first line.
Seems to execute with or without one, for I get the permission denied message with
the error "permission denied" in red.
#! /usr/local/bin/perl -w
I tried the one above, even though another msg here says no path is needed for Windows Hosting.

It's either a permissions problem, or the syntax is different with ActivePerl for Windows, which is what the FAQs on netsol say is being provided. I've searched the activestate website, but can find nothing that tells me I have to do anything special.

If there were, you'd think NetSol could have that in a Perl primer, that there are differences between regular Perl and ActivePerl.

Note, I've also tried this Perl script in the cgi-bin folder, same error.
Go to the top of the page
 
+Quote Post
kyboy
post Sep 4 2008, 03:30 PM
Post #4





Group: Verified NS Member
Posts: 155
Joined: 31-August 08
From: ky
Member No.: 2,243



In Account Manager > Hosting Control Panel > Web Hosting > Security > Password Protection
I clicked on the Web Folders tab
then clicked on the Add button.

I then added the subfolder (for example ggg) and gave it Access Write privilege.

On this page, to the left of the text box provided to enter the subfolder name, it
had "/htdocs" which is my default folder, so I assume that I just gave Access Write privilege to "/htdocs/ggg".

I then retried my perl script (which resides in "/htdocs/ggg"), but still get permission denied trying to open the output file and the file does not show up in the folder after the execution.

I then gave the privilege "Directory Browse" on the ggg subfolder. Still no luck.
Go to the top of the page
 
+Quote Post
kyboy
post Sep 11 2008, 07:51 AM
Post #5





Group: Verified NS Member
Posts: 155
Joined: 31-August 08
From: ky
Member No.: 2,243



In ManageAccount > View Usage Details
I see where Perl (and others) are "Available"
rather than "Enabled" like lots of other things.
Does Perl need to be "Enabled" for my account by NetSol?
Go to the top of the page
 
+Quote Post
Craig
post Sep 11 2008, 12:06 PM
Post #6





Group: Administrators
Posts: 802
Joined: 23-June 08
From: Pennsylvania
Member No.: 1,317



QUOTE (kyboy @ Sep 11 2008, 09:09 AM) *
In ManageAccount > View Usage Details
I see where Perl (and others) are "Available"
rather than "Enabled" like lots of other things.
Does Perl need to be "Enabled" for my account by NetSol?


Only items which you can turn on or off through the Account Manger will show "Enabled" or "Disabled." Items which show "Available" are on by default and cannot be turned off.

There are issues writing to the folder you configured with "Access Write," and our second level support is currently working to resolve the issue.
Go to the top of the page
 
+Quote Post
kyboy
post Sep 16 2008, 08:36 AM
Post #7





Group: Verified NS Member
Posts: 155
Joined: 31-August 08
From: ky
Member No.: 2,243



I tried put the perl script in the cgi-bin folder, but that didn't help.

I called the 800 number yesterday and the rep said he would add a note to the support team to point out that I've been waiting since Sep 4th for an answer.

I also stated that if they need to blow away my folders and recreate, I can FTP all my content back.
Go to the top of the page
 
+Quote Post
kyboy
post Sep 18 2008, 03:19 PM
Post #8





Group: Verified NS Member
Posts: 155
Joined: 31-August 08
From: ky
Member No.: 2,243



Got an email from support Sep17, 10pm EST telling me to call support.
I did that at 3pm today.

Rep uploaded path.asp, which, when I execute, shows me the complete path
to my base folder htdocs.

The complete path is something like (edited here, for security reasons)
E:/a/1/5555/555/565656/user/88332277/htdocs

So I plugged in that path to my open statement in my Perl script, like so
open (DAWG, ">E:/a/1/5555/555/565656/user/88332277/htdocs/aa/DAWG4.txt")
and it works!

That's sorta ugly, though.
IMHO, if I supply just the file name with no path, the file should be read/written from/to
the folder that the Perl script is sitting in, like with most other languages.
Am I missing something?

Regards,
Perl noob.
Go to the top of the page
 
+Quote Post
OscarsPal
post Mar 25 2009, 02:33 PM
Post #9





Group: Verified NS Member
Posts: 1
Joined: 16-March 09
Member No.: 3,982



QUOTE (kyboy @ Sep 18 2008, 04:37 PM) *
Got an email from support Sep17, 10pm EST telling me to call support.
I did that at 3pm today.

Rep uploaded path.asp, which, when I execute, shows me the complete path
to my base folder htdocs.

The complete path is something like (edited here, for security reasons)
E:/a/1/5555/555/565656/user/88332277/htdocs

So I plugged in that path to my open statement in my Perl script, like so
open (DAWG, ">E:/a/1/5555/555/565656/user/88332277/htdocs/aa/DAWG4.txt")
and it works!

That's sorta ugly, though.
IMHO, if I supply just the file name with no path, the file should be read/written from/to
the folder that the Perl script is sitting in, like with most other languages.
Am I missing something?

Regards,
Perl noob.



Well, I ran into the same problem, but I found a slightly more elegant and dynamic solution.

Somewhere in the script, before you need the file name, you can code the following:

# Build the base path to files
$Path = $ENV{PATH_TRANSLATED};
$BasePath = substr($Path,0,(rindex($Path,"\\") + 1));

This sets $BasePath = to your long path string, up to, but not including, the file name. Note that it will be the folder in which the executing script is located, so yo might have to make other adjustments if your file is not there (mine was).

When you need to use the file, you can code this:

$RealPath = $BasePath . "DAWG4.txt";
open (DAWG,">$RealPath");

This is nicer looking, and has the advantage of not forcing you to code the full path as a literal in the script.

Regards,
Oscarspal
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
Tags
No Tag inserted yet

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version    Network Solutions © 2011 Time is now: 27th August 2014 - 03:39 PM
Domain Names | Web Hosting | Web Design | Shopping Cart Software | Online Marketing | SSL Certificates