|
|
#1 |
|
Prospect
Join Date: May 2002
Location: Europe
Posts: 45
|
shell scripting greenhorn question.....
When I create a shell script like the following:
#!/bin/sh cd /Volumes/Internet/eDonkey2000/mldonkey-distrib/ ./mldonkey > mldonkeylog.log how do I manage to make the script work by a command? Do I need a file like mycommand.command and put it into a specific directory? I tried to do this and placed mycommand.command on the desktop, but I always get an error message that the file could not be found. What I want to have is getting the script to work after entering e.g. donky<return> in the terminal. |
|
|
|
|
|
#2 |
|
Triple-A Player
Join Date: Jan 2002
Location: Toronto, Canada
Posts: 185
|
Make it executable with chmod ogu+x filename
Put it in a directory that is in your path. Check your path with: echo $PATH. I would recommend that you put it in /Users/yourname/bin/. Create the directory if it does not exist. Move the file there, then type: rehash (to reinitialize your path programs). By the way, you could run it from the desktop if you use its full path. If a program is not executable, call it with sh filename.
__________________
Novajo |
|
|
|
|
|
#3 |
|
League Commissioner
Join Date: Jan 2002
Posts: 5,536
|
a couple of things need to be done.
1. make it "executable" 2. put it in your "path" it does not need to be extension'd with .command, but that enables it to be finder double-clickable. to make it executable, you'll want to change it's file "mode": Code:
% chmod u+x donkey it to the target dir: Code:
% echo $PATH /Users/merv/bin:/sw/bin:/sw/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin # if you want the script installed just for your user account, move it to your # ~/bin dir ; if you want it installed system wide, move it to /usr/local/bin # you may need to mkdir ~/bin and modify your login script to add your # ~/bin to your path % mv donkey ~/bin # if you're running a csh shell, you'll need to rehash your path to get it to be # immediately recognized % rehash # test your script % donkey why not execute it directly? Code:
#!/bin/sh # file: ~/bin/donkey - run mldonkey # always use full paths to files in scripts # prepare a tmp dir for easy cleanup, it is bad form to have log file turds # all over the filesystem [ -d ~/tmp ] || /bin/mkdir ~/tmp # ~/tmp there ? if not, create it /Volumes/Internet/eDonkey2000/mldonkey-distrib/mldonkey > \ ~/tmp/mldonkeylog.log [edit: Novajo, what are you doing up?! you beat me to it] Last edited by mervTormel; 07-03-2002 at 07:46 AM. |
|
|
|
|
|
#4 |
|
Prospect
Join Date: May 2002
Location: Europe
Posts: 45
|
thanks to all of you, that did help a lot!
|
|
|
|
![]() |
|
|