Results 1 to 5 of 5
Hi everyone,
I have a perl script called " test " that I would like to run using a different name instead of typing
" perl test "
For example ...
- 05-04-2011 #1Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
executing a perl script
Hi everyone,
I have a perl script called "test" that I would like to run using a different name instead of typing
"perl test"
For example how could I run the script test using the word "locate".
Can somebody please tell me how I can do this?
Thanks a lotOne Love!!!
- 05-04-2011 #2
Not entirely sure what you mean by using the word 'locate'. Are you referring to the locate tool or do you want the command 'locate' to run your script?
If you start your script with:
and issue aCode:#!/usr/bin/perl
it can be executed by cd'ing to that directory and issuing aCode:chmod +x /path/to/script
If you want it executable from anywhere you need to put it in your path. For example you could put it in /usr/local/bin as that is in the $PATH for many distros. To be sure, you can check the path with:Code:./test
and put the script in one of the directories mentioned.Code:echo $PATH
Does that help? Not sure I understood your question entirely about locate.
- 05-04-2011 #3Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Thanks for your reply.
No, I am not referring to the linux command "locate".
It could be any name, let's say "ajax".
I was thinking whether is possible to when I type ajax to run the script called "test".
Something like an alias name or soft link?One Love!!!
- 05-04-2011 #4
Ah cool, gotcha.
3 quick ways I can think of off top of my head:
1. Copy the script and rename it to xyz.
2. Use ln to link to that other script like:
3. Use aliases. For example:Code:ln -s /path/to/script /path/to/new/link
Code:alias blah='scriptname'
- 05-04-2011 #5Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Legend!!!

Thank you.One Love!!!


Reply With Quote