Solved

Cannot execute a Perl Script from the command line

Posted on 2004-10-20
3
1,001 Views
Last Modified: 2013-12-16
I wan't to execute a perl script from the command line.

if I type: "perl hello.pl"

it works fine:

However if I type just: hello.pl

nothing happens I just get "bash: hello.pl: command not found"

How do I get around this, I assume I have to edit my PATH or something to point to my perl executable!!!

Any help....
- Troyh
0
Comment
Question by:Troyh
  • 2
3 Comments
 
LVL 6

Expert Comment

by:de2Zotjes
ID: 12361197
try doing:
cd to teh directory where hello.pl is stored.
chmod a+x hello.pl

This command "tags" the file hello.pl as an executable.

If the file allready is executable then again cd to the directory where hello.pl is stored and do ./hello.pl

If that last one works it means that you stored hello.pl in a directory that is not in the path. There are 2 solutions to that problem:
1) move the file to a directory that is in the path. This would be my choice, the custom for "home" made stuff is to put it either in  /<userhome>/bin or /usr/local/bin
2) add the directory where hello.pl is stored to the path. How to do this depends on the shell you are using.
0
 

Author Comment

by:Troyh
ID: 12362121
It works fine if I put the script into the /usr/local/bin

I am using the /usr/bash SHELL, so how do I update the PATH for this shell?

- Troyh
0
 
LVL 6

Accepted Solution

by:
de2Zotjes earned 50 total points
ID: 12362284
You do not need to now, since the script is in the path by moving it, but..

for bash:
simple update of running environment:

export PATH=$PATH:/the/new/path/element

making this permanent for a single user:
edit the file /<userhome>/.bash_profile
add the export PATH=... line as the last line of the script

making this permanent for all users:
edit the file /etc/profile
I can't give any exact directions, because different disto's have different ideas of what this profile looks like, so updating it is distro dependent.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now