Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Why I get a display "Access is denied" when i run my perl script on my pc?

by snowsky (Initiate)
on Jan 19, 2007 at 21:15 UTC ( [id://595599]=perlquestion: print w/replies, xml ) Need Help??

snowsky has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I installed Perl on my local machine. and I set $classpath and $PATHEXT correctly.

After i type my perl scrip name on my windows cmd window, the "Access is denied" message is displayed.

Could anyone tell me why I could not run my perl script directly?

(I have #!/usr/bin/perl -w in the first line in my perl script)

Thanks

Cindy

  • Comment on Why I get a display "Access is denied" when i run my perl script on my pc?

Replies are listed 'Best First'.
Re: Why I get a display "Access is denied" when i run my perl script on my pc?
by jettero (Monsignor) on Jan 19, 2007 at 21:27 UTC

    I don't think windows supports shebang notation. You probably need to either set up a .pl file assoc or type "perl cmdname.pl." UPDATE: Other than reinstalling your ActivePerl, no, not really. I try not to use windows if I can help it. But I can tell you than in my windows, I can in fact run my perl scripts; so I know it's possible. I tend to call "perl filename.pl" instead though, because I'm never quite sure what windows will do if I'm not specific.

    -Paul

      Hi Paul,

      Could you please tell me how to set up a .pl file assoc in windows?

      Thank you!

      Cindy

Re: Why I get a display "Access is denied" when i run my perl script on my pc?
by fizbin (Chaplain) on Jan 20, 2007 at 13:17 UTC
    I've gotten this error sometimes when the perl script has been transferred to the machine with cygwin tools. (e.g. cygwin ssh, ftp, or wget)

    The issue is that somehow you've managed to get the "execute" permission turned off on that file. This is very unusual on windows, but it's often the normal situation on unix; hence, I've only ever encountered it when I've pulled down a file with cygwin, which emulates a unix environment on windows.

    In any case, the way to fix this if you have cygwin installed is to do chmod a+x filename.pl. If you don't have cygwin, then I'm puzzled as to how you managed to do this to yourself, but you can fix it by right-clicking on the file in an explorer window, choosing "Properties", then the "Security" tab, then "advanced". When you see the list of "permission entries", choose the one corresponding to your user id, hit "Edit", and make sure that the "Traverse Directory/Execute" permission is enabled.

    If you are unable to find the problem by looking at your perl script, the problem may be with perl itself. Did you perhaps install Perl by unpacking the zip file with cygwin's unzip? If so, you'll have to make sure that you grant yourself execute permission to basically everything in your perl directory (setting permissions explicitly on the perl directory will give you a chance to automatically apply the permissions all the way down). You can check if the problem is perl itself by seeing if perl scriptname.pl works. If that doesn't work, then the problem is with the permissions on perl.

    If you're still having trouble, could you tell us:

    1. Whether perl scriptname.pl works (or what error message it gives if it doesn't)?
    2. What cacls scriptname.pl shows?
    --
    @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

      Hi,

      I did unzip all my perl file by using cygwin. But when i ran perl my.pl, it worked.

      the result for executing the cacls my.pl is:

      Microsoft Windows XP Version 5.1.2600

      C:\Mc2_v2\Metcalf1\bin>cacls metcalf.pl

      C:\Mc2_v2\Metcalf1\bin\Metcalf.pl WTAM\cxu:(special access:)

      STANDARD_RIGHTS_ALL

      DELETE

      READ_CONTROL

      WRITE_DAC

      WRITE_OWNER

      SYNCHRONIZE

      STANDARD_RIGHTS_REQUIRED

      FILE_GENERIC_READ

      FILE_GENERIC_WRITE

      FILE_READ_DATA

      FILE_WRITE_DATA

      FILE_APPEND_DATA

      FILE_READ_EA

      FILE_WRITE_EA

      FILE_READ_ATTRIBUTES

      FILE_WRITE_ATTRIBUTES

      BUILTIN\Users:(special access:)

      READ_CONTROL

      SYNCHRONIZE

      FILE_GENERIC_READ

      FILE_READ_DATA

      FILE_READ_EA

      FILE_READ_ATTRIBUTES

      Everyone:(special access:)

      READ_CONTROL

      SYNCHRONIZE

      FILE_GENERIC_READ

      FILE_READ_DATA

      FILE_READ_EA

      FILE_READ_ATTRIBUTES

      Thanks,

      Cindy

Re: Why I get a display "Access is denied" when i run my perl script on my pc?
by starX (Chaplain) on Jan 19, 2007 at 21:33 UTC
    Which Perl do you have installed? ActiveState? If not, give it a shot; I had some great successes with it the last time I had to do anything Perl wise in Windows (which, admittedly, was a while ago).

      Hi,

      my perl version is v5.8.2 built for MSWin32-x86-multi-thread.

      I think it is the ActiveState perl

      Any idea why it doesn't work??

      Thanks

      C.

        Did you install it using the *.MSI installer file or did you use the *.ZIP file? The installer sets up the file associations for you.

        I see that you are using an older version of Perl. Perhaps uninstall it and try installing the latest version.

        Otherwise have a look here.

        However, I don't think it is a file association problem. If the file associations are not right, you get a request to choose a program to run your file, not an "access is denied" box. It looks to me that this has something to do with you not being authorized to access that file or the script runs all right but then does something you have no authority to do.

        CountZero

        "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

        Hmm.... you said you were running this from the command line; what is the exact command that you are using from the prompt to run the script?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://595599]
Approved by jettero
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2024-04-18 08:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found