Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Executable question...

Status
Not open for further replies.

Vallurupa

Programmer
Oct 17, 2001
38
US
Hi,

I am new to perl. I am working on linux. My perl script will read the STDOUT when execute some commands and parse those results and show at the commandline. My question is I can only run my perl script when I am in my perl file directory.

%lssyscfg -r sys | perl cs.pl

I want to make my script to run any where in the system . Is possible. Can I make exicuitabe and keep it in the path. So that I can run run my script any where in the system..

Thanks in advance.
Venkat
 
What error do you get when you try to run it outside your perl file directory?
 
Hi John,

I have set the path as follows.
% export PATH =/home/v2aicvp/perl:$PATH
% echo $PATH
When I see the path.. it is saved in my path

my perl script file in the /home/v2aicvp/perl/csv.pl directory.

I am trying to run
/home% perl csv.pl
Can't open perl script "csv.pl": No such file or directory

Now I tired with following way. it found the file.. but it could not execute the perl script....
/home% perl -S csv.pl
Can't execute /home/v2aicvp/perl/csv.pl.

Here is my simple code for example..


#! /usr/bin/perl
print "Hello World" ;


Please help me in this..

Thanks
Venkat
 
Hi,

Try this

In your .profile, have this path rather than exporting it like that.

PATH=:home/v2aicvp/perl
EXPORT PATH

execute your .profile once again and try.

you can say csv.pl at command prompt.

Hope this helps.
 
You can also say

perl ./csv.pl

and bypass any path issues.

 
Hi
I tried

export PATH=:home/v2aicvp/perl:$PATH

It is working fine.

Thank you
venkat
 
TRY CODING FULLY QUALIFIED NAMES FOR EVERTHING THEN THE SYSTEM
SHOULD BE ABLE TO FIND IT. THE FOLLOWING EXAMPLE IS IN A WINDOWS ENVIRONMENT BUT SHOULD WORK IN LINUX/UNIX.

C:\>C:\PERL\BIN\PERL C:\MYFOLDER\MYPROG.PL
<C:\OTHERFOLDER\DATA.TXT >C:\ANYPLACE\OUTDATA.TXT

THE TWO LINES ABOVE ARE ONE LONG LINE. IF YOU WANT TO USE IT IN A PIPE STRUCTURE AS YOU SHOW IN THW WRITEUP THEN THIS SHOULD WORK.

TYPE | C:\>C:\PERL\BIN\PERL C:\MYFOLDER\MYPROG.PL
>C:\ANYPLACE\OUTDATA.TXT
 
If your perl binary is in your home directory and you have;

#!/usr/bin/perl as your shebang line then running the script will always return &quot;file not found&quot; since you don't have a /usr/bin/perl.

try replacing the shebang with

#!/home/v2aicvp/perl if that is where your perl binary ACTUALLY is.
 
Hi Greadey,

Thanks for the post. Actually my perl binary is at /usr/bin/perl only.

my csv.pl file is stored in this path /home/v2aicvp/perl/csv.pl

So I was trying to run this file any where in the system.

Now I copied the file csv.pl to

/usr/bin/

Now I am running this from any where.

% csv.pl
it is working fine...
Thanks again.

Venkat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top