Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.
Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.
Let us assume that the above lines are stored in a Unix file ~/bin/hello. (That's in your home directory, subdirectory bin, file hello.) You can then run the program by entering a command like:
perl ~/bin/hello
perl ~/bin/hello Citizens of Earth
perl hello (If you're in the ~/bin directory.)
If you expect to use this program a lot and want to execute it as a command, then you need to do five things.
1. The first line of the program should after a "#!" specify the location of the perl command, typically as #!/usr/local/bin/perl or #!/usr/bin/perl , as illustrated in the preceding example program. This line can also give command options, like -w (warn of possible inconsistencies).
2. Set the execute permissions of the program file. To make the file executable (and readable and writable) by only yourself, use a Unix command like:
chmod 700 ~/bin/hello
To make it executable and readable by all enter a Unix command like the following:
chmod a+rx ~/bin/hello
You may also need to use chmod a+x on the directories ~ and ~/bin. See "man chmod" for details and the security implications. (The MU program "chweb" can make a file accessible to the Web server and yourself, but not to other users. See "man chweb" for details.)
3. Edit your file ~/.cshrc or ~/.login to make directory ~/bin part of the path Unix searches for executables, with a line like this:
set path = ($path ~/bin)
4. This takes effect the next time you start a default tcsh or csh shell (.cshrc file) or login (.login file). If you want it to take effect immediately, enter the above set path command at the Unix prompt or enter execute your .cshrc or .login file with the "source" command. If you are using sh, bash, ksh or some other shell, alter ~/.profile or some other file to set the path at login.
If a program you want to execute has just been newly created, then issue the csh/tcsh command "rehash" to rescan the path.
If you perform (1)-(5), then you can execute your program via a command like this: