You are not logged in.
Hey there!
I've been trying to develop a script that would allow automatic mounting of a FTPS server, opening of pcmanfm and, on its closure, unmount the server.
Currently, it is split in two files (one interpreted by bash and the other interpreted by expect):
#!/bin/bash
# Connect to wireless network phoenix at home
password=$(zenity --title "SSH Password" --entry --text "Password:")
./mount-ftp-acid-dev $password
pcmanfm /mnt/ftp/domain
fusermount -u /mnt/ftp/domain
#!/usr/bin/expect
# Mount Acid Lounge Devel FTP
set password [lrange $argv 0 0]
set timeout 60
spawn sshfs revolt@domain:/ /mnt/ftp/domain -C -p 22
expect "*?assword*"
send -- "$password\r"
expect "\r"
The problem is that the second script doesn't seem to work. If I execute sshfs... manually and enter the password on the terminal it works fine. However, when I execute that script, I see sshfs asking for the password and then the 'send' command does its thing and sshfs exits. However, if I go to the mount folder it is empty :X Even if I just execute the 2nd script and put the password directly on the 'send' command it seems to fail. What might be causing this?
Appreciate all the help you can give me
Last edited by Revolt (2009-06-25 13:12:44)
Offline
Ok following this topic which kinda reflects my situation I was able to get it working:
http://ubuntuforums.org/showthread.php?t=577454
Only problem now is that the bash script only functions properly if there's no open instance of pcmanfm. Otherwise it races through the pcmanfm call (I guess it uses the already created process instead of creating a new one) and unmounts the folder. A possible solution for this would be to use a separate file manager but this would be a bloated solution. Any good ideas?
Offline
Why not just check in your script if pcmanfm is running, and make further file manager calls depend on that?
You can easily use
pgrep pcmanfm
which evaluates by itself, so you can do
pgrep pcmanfm && echo "Dude I'm still here"
or
pgrep pcmanfm || pcmanfm --options
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
For the sshfs piece, you would be better off using keys instead of passwords.
Offline
For the sshfs piece, you would be better off using keys instead of passwords.
Why? Just for the convenience of not having to type it everytime or is there another reason concerning security?
And regarding B's suggestion, I could indeed check if it already running but it doesn't really help me in this case. Unless there's a way to 'monitor' the running pcmanfm process and wait till it closes before unmounting
Offline
Security, yes, but in this case convenience also, as you don't have to concern yourself with scripting the password negotiation stage.
Offline
Hey guys, just for the record, you don't really have to complicate the thing with expect here. If you provide the password_stdin option to sshfs, you can simply pipe in the password on the command line, like so:
echo myverysecretpasswordpleasedontstealme | sshfs me@myserver:/home/me/Music /home/me/Music -o follow_symlinks,password_stdin,uid=1000,gid=1000,umask=555
Voila
Offline
Or... you could use autofs+sshfs and treat your remote server just like any other directory.
Offline
Except that would be off-topic for this question, as that would still require you to either supply a password or set up key file authentication.
Offline