![]() |
Hello again!
Thanks for all your help. Scripting is not something Im very good at, so Im sorry about asking the same questions over and over... Hope someone can clarify a few things for me: 1. Where do I create the shellscript (textedit or terminal)? 2. Where should I save it 3. If its called "backup.sh" or "backup.command", how will I start it from the terminal? I need to be able to do this both from the prompt and within the daily routine 4. Should it be saved as *.sh or *.command? 5. Below I have tried to make the script as I have understood your feedback. Does it seem correct? #!/bin/bash #this script will run rsync on home directory to a set NAS share /sbin/mount afp://admin:admin@192.168.0.107/sonos/ /usr/bin/rsync -r -o -u -e /Volumes/Machintosh HD/Users/Me/ /Volumes/192.168.0.107/sonos/ Thanks again for your help :) |
The script looks fine, you can create it in any text editor. I prefer text wrangler (google it, free download) but you can use Apple's text edit. Make sure that you you set text edit's preferences to always run as plain text. If you make a script as rich text it will not work.
Save the file as .sh. Now, you can set up a cron job, or apple script to make it executable in the finder. The cron job will run the script at set time and date, and repeat as need be. The apple script would make it have the ability to run with in the finder not having to use the terminal. |
Thanks for your help!
So /path/to/backup.sh added to the /etc/daily would do the trick as a schedule. And an AppleScript to make it excetutable manually? |
check out these links they explain it in more detail
http://www.macosxhints.com/article.p...01020700163714 on this link scroll down to the crontab part http://www.macdevcenter.com/pub/a/ma...minal_one.html |
Thanks again :)
|
Hello again!
I cant make the script work in applescript... tell application "Finder" mount volume "afp://admin:admin@192.168.0.107/sonos/" end tell Works great and the disk connects. However, Im not able to make the script run: do shell script /Users/Me/Desktop/Backup.sh What would the syntax for this part be? Can both functions be in the same script? Thanks again for your help :) |
Try:
do shell script "/Users/Me/Desktop/Backup.sh" |
That seems to work. However, now I get an permissions denied message..
It does not help to put sudo in fornt of /usr/bin/rsync |
Do you have permission to execute the script: /Users/Me/Desktop/Backup.sh
Post what you see if you type this in a terminal window: ls -la ~/desktop/Backup.sh |
if he created it, he should have ownership, which by default gives you rwx permissions.
Are you logged in as administrator? You may want to delete your bash profile under your user account, or better yet test it under a new user account and see if it still denies permission. |
Quote:
|
Really? In my experience everything I create script wise is owned by my user account, even in text edit. I typically save things in my home directory in a folder called 'scripts' then once it is fully tested I duplicate it and toss it on the network or the local client machines.
|
Yes, it's owned by your user account, but TextEdit doesn't make its files executable. That would make the file rw– instead of rwx, so while it could be read or written to, it couldn't be executed as a script.
A simple: chmod 7?? filepath should take care if it, assuming that's the problem. |
Oh, the difference is I always execute scripts manually, with the sh command, before I change ownership and permissions (to make it owned by root or whatever).
So, that is where I was getting confused, but a simple chmod +x /path/to/script will make it executable. |
The preferred method:
Quote:
|
well the difference is, +x makes it executable across the board, where the numbers 751 are for owner, group, everyone. So, you have more control. Each method has its use.
|
| All times are GMT -5. The time now is 05:44 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.