Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rate Thread Display Modes
Old 02-16-2013, 08:55 AM   #1
MacPC
Prospect
 
Join Date: Jun 2008
Posts: 21
script startup command

Hi,
I want to setup my personal Dropbox between my home server and the work station in the office. I followed this tutorial http://www.danbishop.org/2011/09/10/...-in-os-x-lion/ and get it working.

The trouble now is I am not sure how I can make it to start on boot.

I have to enter this command every time after a reboot.
sshfs user@xxx.xxx.xxx.xxx:/Volumes/data/myDropbox /Volumes/data/Desktop/myDropbox
then enter the password.

My scripting skill is rather limited.
Can anyone offer me some guidance how I can write a shell script or Apple script to accomplish this?

I am on OSX 10.8.2.

Thanks in advance.

Last edited by MacPC; 02-16-2013 at 09:00 AM.
MacPC is offline   Reply With Quote
Old 02-16-2013, 10:20 AM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,938
See: https://www.google.com/search?q=os+x...cript+at+login
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 02-16-2013, 11:26 AM   #3
NovaScotian
Hall of Famer
 
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 4,945
Alternatively, you could use Scenario
__________________
17" MBP, OS X 10.8.3; 27" iMac, OS X 10.8.3
NovaScotian is offline   Reply With Quote
Old 02-16-2013, 04:14 PM   #4
MacPC
Prospect
 
Join Date: Jun 2008
Posts: 21
Hi thanks all for replying.
After some research I made this script called myDropbox.sh

#!/usr/bin/myDropbox
spawn sshfs user@xxx.xxx.xxx.xxx:/Volumes/data/htdocs/myDropbox /Volumes/data/Desktop/myDropbox
expect "Password"
send "myPwd\r"
interact

When I run it in Terminal, it seems like it was going to start because after the password and returns to the $ prompt.
but it doesn't start. As I said my unix commands are rusty, can someone spot something wrong with the commands?

Thanks again.
MacPC is offline   Reply With Quote
Old 02-17-2013, 01:54 AM   #5
benwiggy
League Commissioner
 
Join Date: Aug 2006
Posts: 5,039
Can I ask a stupid question? Why not just install the Dropbox app?

That will ensure you have access to your Dropbox account through the Finder on each machine, automatically at login.
You already have to install stuff to get this to work, in any case.
benwiggy is offline   Reply With Quote
Old 02-17-2013, 08:38 AM   #6
MacPC
Prospect
 
Join Date: Jun 2008
Posts: 21
@benwiggy
"Can I ask a stupid question? Why not just install the Dropbox app?"

Well,

For one, my server has 2T of storage.
And more importantly, it's more fun and satisfying to be a creator than a consumer, because in the process I learn something. I know, I am a big NERD!

Last edited by MacPC; 02-17-2013 at 08:43 AM.
MacPC is offline   Reply With Quote
Old 02-19-2013, 06:51 AM   #7
MacPC
Prospect
 
Join Date: Jun 2008
Posts: 21
I did it, Yea!

For those who are interested

First set ssh to use ssh key authentication to by pass the password requirement.

Then in AppleScript Editor

Here is what my AppleScript looks like:

/* ======= */
tell application "Terminal"
do shell script "/usr/local/bin/sshfs user@xxx.xxx.xxx.xxx:/path_of_ remote_directory ~/Desktop/your_Dropboxname"
end tell
/* ====== */

Save it as Application in AppleScript Editor.

Put the App in login items. VOLIÁ! the next time you start your Mac the virtual drive sits there like a real drive.
MacPC is offline   Reply With Quote
Old 02-19-2013, 07:11 AM   #8
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,045
The answer to this question might be "the other computer is not a Mac", but why don't you just use afp and built-in File Sharing?
acme.mail.order is offline   Reply With Quote
Old 02-19-2013, 07:38 AM   #9
benwiggy
League Commissioner
 
Join Date: Aug 2006
Posts: 5,039
I'm not sure that you need to tell Terminal to do a shell script. I think you can just "do one".
benwiggy is offline   Reply With Quote
Old 02-19-2013, 07:54 AM   #10
MacPC
Prospect
 
Join Date: Jun 2008
Posts: 21
@acme.mail.order "why don't you just use afp and built-in File Sharing?"
To make my boss feel more at ease when I work away from the office? :}

@benwiggy " I'm not sure that you need to tell Terminal to do a shell script. I think you can just "do one""

Perhaps it is not needed, I will have to try it went I got home. Good point!
MacPC is offline   Reply With Quote
Old 02-19-2013, 08:09 AM   #11
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,045
Yes, you can:

do shell script "command -o -p --tions"

pitfalls:

- it's sh, not bash
- your normal environment is NOT loaded
- repeat uses of do shell script are in a new shell
- escaping quotes and spaces rapidly becomes a nightmare as you must escape from both the shell and Applescript in the correct order.
acme.mail.order is offline   Reply With Quote
Old 02-19-2013, 07:22 PM   #12
MacPC
Prospect
 
Join Date: Jun 2008
Posts: 21
@benwiggy you are right. I don't need the "do shell script" , but seems like AppleScript Editor complains if I use "do one", I changed the script to this, it works just fine. and
@acme.mail.order
Thank you both.

/* ======= */
do do shell script "/usr/local/bin/sshfs user@xxx.xxx.xxx.xxx:/path_to_ remote_directory ~/Desktop/your_local_Dropbox_name"
/* ====== */

Last edited by MacPC; 02-19-2013 at 07:29 PM.
MacPC is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 03:21 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, 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.