| jhagge@gmail.com 2006-10-23, 7:21 pm |
| Thanks for the replies. I am trying to implement some of the
suggestions, but it is slow going. Chris, I will answer your questions
below:
> I don't understand this. If you don't know where DOGFOOD is, how
> will you create a file in it? If you intend for the user to run this
> script while DOGFOOD is his current directory, then you can get
> the full path for DOGFOOD with "pwd", which prints the full path
> of the current directory.
The user will be downloading a folder called DOGFOOD and the script
will reside in this folder along with some other files that need to be
copied to a specific location on the hard drive. I don't know or have
control over where the DOGFOOD folder will be saved on the users
harddrive. So, I need the script to be able to derive a full path
based off of the scripts current location. This is easy with batch
files, but this whole Unix thing is a different world. Maybe there is
a better way to do this than what I am trying to do....
> I'm not entirely sure how OS X does this, but it is supposed be
> to UNIX-based, and in UNIX, there is no such thing as "the system
> drive", there is only one unified directory tree. Drives as
> such are not seen unless you are mounting and unmounting filesystems.
> What are you trying to do and why do you need to copy files
> outside the user's home directory? Where do you want them to go
> and what do you think this will accomplish? Be aware that if it is the
> user that is running the script, it is unlikely that he will have
> permission to write anywhere besides his home directory (and the
> temp directory).
Files need to be copied to a location that is part of OSX
(/Library/Application Support) and outside of the users home folder.
As long as the user is logged into OSX with an account that has Admin
privileges (all these users I am working with will be) they should be
able to copy files here... at least I can do it manually from terminal,
so I don't see why it can't be done with a script. I believe I know
how to do this part now... I am still struggling with my first
question.
Which leads me to a question about the following command suggested
earlier:
dir=$(cd $(dirname "$0"); pwd)
This seems to be what I need, but I don't think I fully understand what
it is doing. For a test, I simply put that line in a new script and
the next line is:
echo $dir
and when i run the script it returns:
/tmp
The script is not saved in /tmp (it is currently saved on a folder in
the users desktop directory). I was expecting that path to be
returned. Setting a variable seems to be the thing to do, I just need
the script to be able to see where its current location is and set a
variable accordingly to reflect this path.
So, either it is not working correctly or I don't understand how it is
supposed to be implemented (i am guessing the latter).
Any hints on this are appreciated!
|