LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Ubuntu 12.04 Cronjob failed to mount ftp share using gvfs-mount (https://www.linuxquestions.org/questions/linux-newbie-8/ubuntu-12-04-cronjob-failed-to-mount-ftp-share-using-gvfs-mount-4175504945/)

BlackMoon 05-14-2014 03:41 AM

Ubuntu 12.04 Cronjob failed to mount ftp share using gvfs-mount
 
Currently I have task to backup some data from ftp server to local pc for every hour in every day.
Say the server is 10.10.10.10 with credentials username and password
When I open the ftp server through Firefox it displays root of the ftp user (eg. /home/username), but when I open it through Nautilus it displays root of the ftp server (eg. /).
I dont know exactly what OS server is running (I think it is Solaris) and the settings, I just given the credentials.
The problem is data that I need to backup is located at the root of the ftp server (eg. /backup), so I have to mount it like Nautilus does.
Also I have tried curlftpfs, but it mounts ftp server like Firefox does.
I googled and found that to mount ftp server like Nautilus does was using gvfs-mount
So I wrote some shell script to automate this task. Here what I got :

#!/bin/sh
$ftp_user="username"
$ftp_pass="password"
$ftp_host="10.10.10.10"
echo "$ftp_pass" | /usr/bin/gvfs-mount 'ftp://'$ftp_user'@'$ftp_host
ftp_dir=$(find "$HOME/.gvfs/" -path "*$ftp_host*" -print -quit)
### Do backup here
/usr/bin/gvfs-mount --umount "$ftp_dir"

I named the script as backup.sh, added execute bit, run it from Terminal (eg. ./backup.sh), and nothing unexpected was happened.
So I added that script to my cronjob (eg. 0 * * * * /home/myusername/backup.sh 2>&1 | /usr/bin/logger -t "TEST_CRONJOB"), but the ftp was not mounted.
When I checked the log, the error was :

TEST_CRONJOB: Error mounting location: volume doesn't implement mount
TEST_CRONJOB: Error finding enclosing mount: Containing mount does not exist

So, my question is : Is there something I need to configure before using cron and gvfs-mount ?
Thanks in advance

jpollard 05-14-2014 03:49 AM

If you are already logged in, thus I believe gvfs is already mounted. Trying to mount over a mount with gvfs doesn't work as gvfs doesn't support the mount function.

BlackMoon 05-14-2014 04:03 AM

Quote:

Originally Posted by jpollard (Post 5170539)
If you are already logged in, thus I believe gvfs is already mounted. Trying to mount over a mount with gvfs doesn't work as gvfs doesn't support the mount function.

Thank for your reply, but I havent logged in yet (do you mean to ftp server?) and I dont have any mounted ftp in my .gvfs folder

jpollard 05-14-2014 08:17 AM

The place you are trying to mount doesn't allow you to mount.

Since all of this appears to be taking place on your local machine, it would be there.

schneidz 05-14-2014 09:02 AM

my opinion is that it would be more secure and easier to use scp with private-key-encryption. there is also sshfs which will mount remote directories using ssh.

BlackMoon 05-15-2014 02:36 AM

Quote:

Originally Posted by jpollard (Post 5170688)
The place you are trying to mount doesn't allow you to mount.

Since all of this appears to be taking place on your local machine, it would be there.

Is this about permission?
I have chown'd and chgrp'd the the mount point on my local pc.



Quote:

Originally Posted by schneidz (Post 5170718)
my opinion is that it would be more secure and easier to use scp with private-key-encryption. there is also sshfs which will mount remote directories using ssh.

I havent tried sshfs yet because my work is off right now, but I have tried using scp on my another local pc.
Here what I got :

#!/bin/sh
echo password | /usr/bin/scp username@host:/path/to/some/file /home/myusername

I added that script to cronjob and it doesnt work.
The report I got :
TEST_CRONJOB: Permission denied, please try again.#015
TEST_CRONJOB: Permission denied, please try again.#015
TEST_CRONJOB: Permission denied (publickey,password).#015

When I tried it on Terminal, it seems that echo didnt pipe password to scp.
Any ideas?

jpollard 05-15-2014 10:16 AM

Quote:

Originally Posted by BlackMoon (Post 5171222)
Is this about permission?

No. It is about functionality not implemented. gvfs is not a real filesystem. It is a process that interprets filesystem requests (passed via FUSE). and the mount request is not supported.
Quote:


I have chown'd and chgrp'd the the mount point on my local pc.
...

I havent tried sshfs yet because my work is off right now, but I have tried using scp on my another local pc.
I would expect sshfs to work better as the mount is done on the local system, using the users directory (I believe it creates/can create the local directory mountpoint), and the file requests are passed to the sshfs service running on the remote end, thus no mount on the remote.
Quote:

Here what I got :

#!/bin/sh
echo password | /usr/bin/scp username@host:/path/to/some/file /home/myusername

I added that script to cronjob and it doesnt work.
The report I got :
TEST_CRONJOB: Permission denied, please try again.#015
TEST_CRONJOB: Permission denied, please try again.#015
TEST_CRONJOB: Permission denied (publickey,password).#015

When I tried it on Terminal, it seems that echo didnt pipe password to scp.
Any ideas?
Echo cannot. ssh/scp use a secure channel to read the password by opening /dev/tty. chron jobs don't have a tty... The "permission denied" is because the attempt to open /dev/tty fails.

schneidz 05-15-2014 11:10 AM

Quote:

Originally Posted by BlackMoon (Post 5171222)
...I havent tried sshfs yet because my work is off right now, but I have tried using scp on my another local pc.
Here what I got :

#!/bin/sh
echo password | /usr/bin/scp username@host:/path/to/some/file /home/myusername

I added that script to cronjob and it doesnt work.
The report I got :
TEST_CRONJOB: Permission denied, please try again.#015
TEST_CRONJOB: Permission denied, please try again.#015
TEST_CRONJOB: Permission denied (publickey,password).#015

When I tried it on Terminal, it seems that echo didnt pipe password to scp.
Any ideas?

:facepalm:
http://linuxproblem.org/art_9.html

BlackMoon 05-15-2014 11:40 AM

Quote:

Originally Posted by jpollard (Post 5171428)
No. It is about functionality not implemented. gvfs is not a real filesystem. It is a process that interprets filesystem requests (passed via FUSE). and the mount request is not supported.


I would expect sshfs to work better as the mount is done on the local system, using the users directory (I believe it creates/can create the local directory mountpoint), and the file requests are passed to the sshfs service running on the remote end, thus no mount on the remote.


Echo cannot. ssh/scp use a secure channel to read the password by opening /dev/tty. chron jobs don't have a tty... The "permission denied" is because the attempt to open /dev/tty fails.

I have tried schneidz link and it worked on my local network. I will try it next day on my work.
Thanks



Quote:

Originally Posted by schneidz (Post 5171465)

Thanks for the link


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