perl self-executable

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

gamemaster_bm2

Thread Starter
Joined
Jul 31, 2001
Messages
78
i just started learning to use perl, and i cant seem to get my programs to execute without invoking perl to compile it
i tried everything in the man pages, and cant seem to figure it out
its proabably some little thing im overlooking, but help would be appreciated
Running Mandrake-Linux 8
 
Joined
Feb 11, 2002
Messages
1,405
A couple of thoughts:

(1) have you make sure that the perl program is executable? Typically, you would use a command such as chmod 755 perl-program-name or chmod a+x perl-program-name to set the execute bit for all users. If you type ls -l perl-program-name and see something such as rw-rw-rw (i.e., without an x in any position), then the chmod command should do the trick. Note that you must be the owner of the script or root in order to modify the permissions.

(2) have you verified that the first line in your script is something like: #! /usr/bin/perl? This directs the shell to use /usr/bin/perl as the interpreter for the script (note that your path to perl may be different). Without this line, you may receive syntax errors and various other complaints, forcing you to invoke the script as perl perl-program-name.

My guess is that the first option is the more likely.

Hope this helps.
 

gamemaster_bm2

Thread Starter
Joined
Jul 31, 2001
Messages
78
im pretty sure its my chmod statement, but i cant figure out why it doesnt turn on the execute bit...
ive tried chmod +x filename, chmod a+x filename, any others?
 
Joined
Feb 11, 2002
Messages
1,405
If you are either root or the owner of the file, chmod a+x filename or chmod +x filename should work, as should chmod 755 filename. You might try running fsck on the filesystem, to make sure there are no problems in the filesystem itself that may affect your results.

Other possibilities: what error(s) do you receive when you try to execute your perl script(s) directly? Note that a "file not found" or similar error may mean that the directory that contains the script to be executed is not in your path; the current directory is typically excluded from root's path for security reasons.

When you execute the chmod command, try capturing the return code -- there may be a clue there. You can try: chmod a+x filename; echo $? to see the return code.

By any chance, is the perl script a symbolic link to another file? If so, you will not be able to change the permissions on a symbolic link (they don't matter, anyway), but the permissions on the file pointed to by the link should change (OK, it's a long shot, I admit ...).

Finally, how is the filesystem mounted? If it is mounted read-only, you will be unable to change any file attributes (although I would expect you'd receive an error message if you attempted to modify anything in the filesystem).

It sure seems like you've covered the obvious bases. Additional info appreciated.

Hope this helps.
 

gamemaster_bm2

Thread Starter
Joined
Jul 31, 2001
Messages
78
i finally got it, i was using the switch -x instead of +x, i dont know why i missed this, but it was a pretty obvious error once i saw it, thanks anyway
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top