Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cannot execute a Perl Script from the command line

Posted on 2004-10-20
3
Medium Priority
?
1,015 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 150 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

618 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