1

I have a bash script that tests whether the sftp connection exists, very simple one:

$ if [ -d ~/.gvfs/sftp for username on 192.168.1.101 ]; then echo "sftp missing" exit; fi

Now heres the question: How do I make the script reestablish the previously connected sftp that still has a cached pass to reconnect without having it depend on if the bash script is on?

Since I have a bookmarked sftp thing in nautilus, i just point and click, presto its reconnected. I need the same for my script which will TERMINATE in a couple of lines; in other words the script only reconnects nautilus and dies, connection stays open...

I am still noobish at sftp, besides connecting...

Extra info: I use Ubuntu for both client and server, and i dont mind entering the ssh pass again if its new conection, any help is appreciated :D

Its critical that sftp wont d/c, or die, when i close script, or it ends, nohup cant be used for script since it will be run >10 times per day

Thanks!

Rupesh Yadav
  • 12,096
  • 4
  • 53
  • 70
krack krackerz
  • 1,399
  • 2
  • 9
  • 13
  • You mentioned entering password each time, check out [passwordless ssh](http://www.debian-administration.org/articles/152) – bbaja42 Jun 12 '11 at 20:42
  • What is a "SFTP connection" here? This is not a standard term, I think. – Paŭlo Ebermann Jun 12 '11 at 20:44
  • @Paulo, sure it is [SFTP](http://en.wikipedia.org/wiki/SSH_file_transfer_protocol) – bbaja42 Jun 12 '11 at 20:55
  • I know what SFTP is, but normally I do not have open connections when I'm not activley transferring files. – Paŭlo Ebermann Jun 12 '11 at 20:58
  • related questions: [How to mount from command line like the Nautilus does?](http://stackoverflow.com/q/483460/600500), [Gnome-mount alternative in Ubuntu 10.04 or how to mount partition with normal user rights](http://superuser.com/q/131918/67711) – Paŭlo Ebermann Jun 12 '11 at 21:01
  • the reason I need to "reconnect" is because I have an opened ssh sftp which I use to stream videos from one comp to another, and when I Hibernate the client comp, the connection needs to be reestablished after turning it back on, so my script needs to remount it, without having to hold it open. I am looking into gvfs-mount now :) . – krack krackerz Jun 13 '11 at 02:47

1 Answers1

0

Okay, some research done. You are using the GVFS (GNOME Virtual File System), and are looking with a none-GNOME application (bash) on the FUSE mount point of one of the URIs.

I think you can use the gvfs-mount command to reconnect, if you know the SFTP URL, but I didn't really find much documentation about this.

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210