run perl script in linux
Here is the perl script test case called hello.pl
#!/usr/bin/perl print "Hello world!\n"; the command to invoke the script in the terminal as: #perl hello.pl How could I execute it without the "perl" prefix as: #hello.pl I have chmod 777 hello.pl #which perl /usr/bin/perl |
Hi,
If the location the script is in is not in your PATH: ./hello.pl Hope this helps. |
You may run any executable file by providing the full (absolute) or relative path.
So assuming you are in your home directory, any of the following can work: Code:
/home/casualzone/hello.pl |
thank you very much!! It works by executing below:
#/app/work/hello.pl The next step / question. If the perl script is located at /app/work/, how could I make it as below in the /app/work/ folder #hello.pl instead of typing #/app/work/hello.pl Reason: I am using the script frequently. That mean i got to export the /app/work/ path into my .bashrc ?? How could I make it? thank you! |
Quote:
And/or read about "bash aliases" - again, use WEB search engine of your liking. |
Hi,
If you want to add something to your PATH you can edit your /etc/profile (make it global for every user) or your ~/.bashrc (or ~/.bash_profile). The latter depends a bit on your distro. As stated already by Sergei Steshenko, search the web for specifics (do include your distro name in the search). Hope this helps. |
If only required on a temporary basis, ie you might move directories later, then you can use the third option from post #3 when in the directory.
|
I have a directory called "bin" in my home dir and I added it to my (and only my) PATH using .bash_profile.
|
All times are GMT -5. The time now is 09:44 AM. |