LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-14-2012, 02:22 AM   #1
hamidi2
Member
 
Registered: Aug 2012
Posts: 61

Rep: Reputation: Disabled
910723 - PATHEXT equivalent?


hi

there's an environment variable in Windows called PATHEXT which includes executable files extensions. i used to write perl scripts instead of batch files, because of limitations of shell programming in Windows. i assign .pl extension for the perl scripts and add .pl to the list of extensions of PATHEXT. this causes me not to have to include the .pl extension each time i want to run the perl script.
now i need the same behavior in Linux.

1. first, let me know where's the best place to put my own general utilities. i don't want it to be /bin, because it's not separated from the system binary files. it's like putting my own utilities in System32 in Windows.

2. what's the best method to add my own directory to path? i want it to happen only in my account for my user. maybe put some commands in .bashrc?

3. now how can i omit the requirement to affirm the .pl extension, so that i just enter the name (not with extension) of the perl script when running it?

thx
 
Old 10-14-2012, 04:58 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Quote:
Originally Posted by hamidi2 View Post
1. first, let me know where's the best place to put my own general utilities. i don't want it to be /bin, because it's not separated from the system binary files. it's like putting my own utilities in System32 in Windows.
2 locations come to mind: /usr/local/bin and ~/bin
The first is global and keeps none-system related binaries away from /(s)bin and /usr/(s)bin. The second is a bin directory inside the home directory, which would make it local for the owner of that home directory ("you").
There are other options, but these are commonly used.

Quote:
2. what's the best method to add my own directory to path? i want it to happen only in my account for my user. maybe put some commands in .bashrc?
The PATH variable holds all the directories that are searched, you can add a directory to this variable. It depends a bit on the distribution you are using, but .bashrc can be used. Add something like this at the end of .bashrc:
Code:
export PATH=$PATH:/my/special/dir
Quote:
3. now how can i omit the requirement to affirm the .pl extension, so that i just enter the name (not with extension) of the perl script when running it?
i'm not 100% sure I understand what it is you want or if you are looking for the correct solution.
Windows is extension based, it looks at (needs) an extension to be able to find out what kind of file is being used. Linux on the other hand does not look at the extension.

If a script has the correct hash-bang, linux will execute/parse this accordingly, no matter what the file name is.
Code:
#!/usr/bin/perl

use strict ;
use warnings ;
.
.
If the above perl snippet is saved as some.name it will be executed using perl. If the file would be called some.name.awk or some.name.sh it would still be executed using perl.
 
1 members found this post helpful.
Old 10-16-2012, 06:48 AM   #3
hamidi2
Member
 
Registered: Aug 2012
Posts: 61

Original Poster
Rep: Reputation: Disabled
that really solved my problem.
thx
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
chkconfig equivalent in hp-ux me_spearhead Other *NIX 1 09-19-2011 10:39 AM
su equivalent rajorshi Programming 0 04-27-2007 05:34 AM
MS Money or equivalent Paulsuk Linux - Software 5 12-15-2005 12:52 PM
VC++ Equivalent on FC3???? ur-unholyness Linux - Newbie 8 02-07-2005 11:08 PM
equivalent to c? codename000 Programming 3 04-03-2003 12:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration