|
|
Another way to create Finder-clickable shell scripts
So you're saying if we set the creator to APPL it's always run as root? Is that a security risk? Say I am a limited user, I download setFile, and create a shellscript called Terminate.sh, and the base code is:
Another way to create Finder-clickable shell scripts
I'm pretty sure he means it's run from the root directory, not as root. That's why he mentions absolute paths...
Another way to create Finder-clickable shell scripts
No, it's an unfortunate overloading of the word "root". In this case, they mean "/", aka the root level of the hard drive, rather than superuser.
Another way to create Finder-clickable shell scripts
You don't need to know, just do a cd with an absolute path.
Another way to create Finder-clickable shell scripts
The key point is that the path must be absolute. /Users/username/Desktop instead of Desktop and so on.
So if you're going to do a lot of things in a specific diretory instead of having:
You can do it like this:
Remember to include
in the top of the shell script to tell that it should be executed by Bash. I'm not sure other shells support the export command.
Another way to create Finder-clickable shell scripts
Oh yeah... if you want to use the script in my example, I would recommend:
this script creates a tar-gzipped file with the date as the name in the home directory of the user username. It appends the list of files to the file /var/logs/savedfiles.txt and removes the files from the original directory
Another way to create Finder-clickable shell scripts
of course you can use cd in a shell script, its just easier to mess up that way... it is a shell after all! :-D
How a shell script can find where it is located
The output of dirname $0 will tell you the directory in which the shell script is located. If your shell script wants to cd to the directory that contains the script itself, it should say
cd `dirname $0` |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|