LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-14-2014, 04:41 AM   #1
BlackMoon
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Rep: Reputation: Disabled
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
 
Old 05-14-2014, 04:49 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
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.
 
Old 05-14-2014, 05:03 AM   #3
BlackMoon
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
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
 
Old 05-14-2014, 09:17 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
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.
 
Old 05-14-2014, 10:02 AM   #5
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,027

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
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.
 
Old 05-15-2014, 03:36 AM   #6
BlackMoon
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
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 View Post
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?

Last edited by BlackMoon; 05-15-2014 at 03:51 AM.
 
Old 05-15-2014, 11:16 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by BlackMoon View Post
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.
 
Old 05-15-2014, 12:10 PM   #8
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,027

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
Quote:
Originally Posted by BlackMoon View Post
...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
 
1 members found this post helpful.
Old 05-15-2014, 12:40 PM   #9
BlackMoon
LQ Newbie
 
Registered: Nov 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by jpollard View Post
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 View Post
Thanks for the link
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting Windows shares with GVFS mount lulatsch Linux - Newbie 1 09-14-2012 09:27 AM
Setting file permissions gvfs-mount samba share? ask Linux - General 1 01-04-2012 10:51 AM
failed to mount windows share gearmouse Linux - Networking 4 03-27-2010 01:53 PM
NFS mount of smb mount of windows share: permission denied problem :( Bagatur Linux - Networking 4 07-07-2009 12:34 PM


All times are GMT -5. The time now is 04:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration