Solved

Cannot execute a Perl Script from the command line

Posted on 2004-10-20
3
1,011 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

705 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