Sshfs script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sshfs script
# 1  
Old 02-17-2013
Sshfs script

Hi, I am new to this forum.

I want to setup my personal Dropbox between my home server and the work station in the office.

I followed this tutorial

danbishop.org/2011/09/10/...-in-os-x-lion/and it works great. Smilie

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.

After some research I made this script called myDropbox.sh

#!/usr/bin/expect
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 mount because after the password it returns to the $ prompt.
but it doesn't mount. Smilie

Can someone tell me what I did wrong?

Thanks in advance.

P.S. I am on OSX 10.8.2

Last edited by macpc; 02-17-2013 at 01:36 PM..
# 2  
Old 02-17-2013
I usually start such with a frequent cron, and make the script discover if it is already running and exit if so. This can take many forms: bind to socket, writing a file, flag file, pid file. Not only do you get reboot restarts, you get restarts for any sort of crash.

However, automounts are the thing for mount points. Does sshfs allow automounts?

If it is ssh based, PPKeys is nicer than password.
# 3  
Old 02-17-2013
Hi DGPickett, thanks for the reply. Please do excuse me, my knowledge in shell scripting is very limited.

"This can take many forms: bind to socket, writing a file, flag file, pid file"
I only need a simple script that can trigger the sshd
or something like that. , I am not concern regarding crashing, it's the boot that matters hence I don't believe corn or binding socket.... is necessary, or is it?

"However, automounts are the thing for mount points. Does sshfs allow automounts?"
May be I am wrong, this line does seem to mount nicely.
sshfs user@xxx.xxx.xxx.xxx:/Volumes/data/htdocs/myDropbox /Volumes/data/Desktop/myDropbox after I enter the password.

Basically I just need the line to execute and enter the password at boot.
I guess my question is why when I run this line user@xxx.xxx.xxx.xxx:/Volumes/data/htdocs/myDropbox /Volumes/data/Desktop/myDropbox in terminal works.
but not when I made it in the script.

Thanks again. Smilie
# 4  
Old 02-17-2013
One thing aboug ssh family commands is that they take the password from /dev/tty not stdin, so you need an expect layer or something similar to inject scripted passwords.

It is not so hard to set up trusted PPKey and not need a password.

A cron driven script might 'echo $$ >$HOME/.my_app_pid' after checking 'if [ 0 = $( ps -u $user -p $(<$HOME/.my_app_pid ) | grep -c $0 ) ]' to make sure old servers are not running. This is what I meant by pid file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

2. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

3. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

4. UNIX for Dummies Questions & Answers

SSH tunnel working for ssh but not for sshfs

I'm trying to setup a link between my home pc (work-machine) and a server at work (tar-machine) that is behind a gateway (hop-machine) and not directly accessible. my actions: work-machine$ ssh -L 1234:tar-machine:22 hop-machine work-machine$ ssh -p 1234 user@127.0.0.1 - shh access on... (1 Reply)
Discussion started by: Vathau
1 Replies

5. Shell Programming and Scripting

ssh, truecrypt, sshfs in a script

Hello all, First time posting, although the site has helped solve many problems in the past! I would like to create a script to simplify a series of commands that I run: Log into the ssh-server (RSA key) ssh username@hostname -p 6110 Once there, I mount a truecrypt volume: truecrypt... (3 Replies)
Discussion started by: freshtoast
3 Replies

6. Solaris

Alternative to sshfs?

I have an automated testing script that relies on the dev box being able to see production's (NFS) share. It uses rsync and ssh to handle transfers and command execution; however, it also needs the production share mounted in order to run Perl code against it when Unix commands via ssh will not do.... (2 Replies)
Discussion started by: effigy
2 Replies

7. Shell Programming and Scripting

Mount twice sshfs dir

Hi everyone. I have 3 machines, let's call them store, node1 and node2. I have to mount on node1 and node2 the same directory of store. So, I launch the sshfs command on node1 and everything works fine. But when I try to do that on node2, it hangs for a while and then I obtain:... (0 Replies)
Discussion started by: canduc17
0 Replies

8. UNIX for Dummies Questions & Answers

sshfs twice on the same dir

Hi everyone. I have 3 machines, let's call them store, node1 and node2. I have to mount on node1 and node2 the same directory of store. So, I launch the sshfs command on node1 and everything works fine. But when I try to do that on node2, it hangs for a while and then I... (0 Replies)
Discussion started by: canduc17
0 Replies

9. Solaris

Solaris 8 and sshfs

Hi, all.. Does Solaris 8 support sshfs? (Sorry if my question is too simple :o) We are going to mount a file system from Solaris 8 on HP-UX 11i. Will things will go smoothly with this? Will there be any performance problem if the number of users grow to perform I/O operations on mounted fs? ... (4 Replies)
Discussion started by: swmk
4 Replies

10. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question