LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 01-26-2011, 11:05 AM   #1
danubuntuman
LQ Newbie
 
Registered: Jan 2011
Location: UK
Distribution: Ubuntu 10.04 LTS
Posts: 5

Rep: Reputation: 0
File transfer: scp from local to windows share


Hi there,

I'm running Ubuntu 10.04 LTS, fresh install, and have been searching far and wide for the answer to this. I think it is probably either something simple, or i'm doing something fundamentally wrong...

1) I have a script which puts all my files into a tar.gz file in a local directory.
2) I have a 'Windows share' mounted using a tool found in 'Places>Connect to server'
This mounts the server to:
Quote:
/home/dan/.gvfs/dan\ on\ servername.ac.uk
3) I wish to copy my backup to the mounted Windows server. So i use the command:
Quote:
scp backup_26-01-2011.tar.gz /home/dan/.gvfs/dan\ on\ servername.domain.ac.uk/backup/
And this completes nicely.

....Start of problem:

4)I wrote a bash script to allow this to run as a cron job:
Quote:
#!/bin/bash
zipname='dan_'`date +%d-%m-%Y`'.tar.gz'
source='/home/dan/temp_backups'
target='/home/dan/.gvfs/dan\ on\ servername.domain.ac.uk/backup/'

scp $source/$zipname $target
The target is correct (browsed there via terminal, and used 'pwd'), but the error i get back is:

Quote:
servername.domain.ac.uk/backup/: No such file or directory
Is there anything particularly wrong with what i'm attempting? My best guess is that the spaces in the mount name are causing a problem, but i've tried using quotation marks in the form of:
Quote:
target='/home/dan/.gvfs/dan\ on\ servername.domain.ac.uk/backup/'
and
Quote:
target='"/home/dan/.gvfs/dan\ on\ servername.domain.ac.uk/backup/"'
Without any change in error message, both when i do and do not include backslashes.

Any help would be much appreciated!

Last edited by danubuntuman; 01-26-2011 at 11:07 AM.
 
Old 01-26-2011, 12:35 PM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 249Reputation: 249Reputation: 249
Greetingz!
Well, for starters, you should probably make a few changes to your script;
Code:
#!/bin/bash
zipname="dan_`date +%d-%m-%Y`.tar.gz"
source="/home/dan/temp_backups"
target="/home/dan/.gvfs/dan\ on\ servername.domain.ac.uk/backup/"
cd ${target}
[ $? -gt 0 ] && \
  {
    print "Cannot find target ${target}! Exiting!"
    return 1
    exit
  } || {
    print "Target found!"
    scp ${source}/${zipname} ${target} 
  }

Last edited by xeleema; 01-27-2011 at 02:13 PM.
 
1 members found this post helpful.
Old 01-27-2011, 05:40 AM   #3
danubuntuman
LQ Newbie
 
Registered: Jan 2011
Location: UK
Distribution: Ubuntu 10.04 LTS
Posts: 5

Original Poster
Rep: Reputation: 0
Hi xeleema, thanks for your reply.

I tried putting the code you suggested into my bash script after the part i try to 'scp', and got this back:

Quote:
servername.domain.ac.uk/backup/: No such file or directory
./daily_backup.sh: line 42: cd: /home/dan/.gvfs/dan\: No such file or directory
Warning: unknown mime-type for "Cannot find target /home/dan/.gvfs/dan\ on\ servername.domain.ac.uk/backup/! Exiting!" -- using "application/octet-stream"
Error: no such file "Cannot find target /home/dan/.gvfs/dan\ on\ servername.domain.ac.uk/backup/! Exiting!"
./daily_backup.sh: line 46: return: can only `return' from a function or sourced script

Last edited by danubuntuman; 03-02-2011 at 10:15 AM.
 
Old 01-27-2011, 05:49 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Main: Gentoo Others: What fits the task
Posts: 15,592
Blog Entries: 2

Rep: Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047Reputation: 4047
May I ask why you use scp (a tool for copying over the network using SSH) to copy to a local mounted share? Try it with cp instead.
 
Old 01-27-2011, 05:52 AM   #5
chickenjoy
Member
 
Registered: Apr 2007
Distribution: centos,rhel, solaris
Posts: 200

Rep: Reputation: 30
q) if the windows share is mounted locally (via samba); then you can just use "cp" instead.

cp <path_to_file> <windows share mounted directory>

TobiSGD beat me to it.
 
Old 01-27-2011, 02:18 PM   #6
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 249Reputation: 249Reputation: 249
Argh, I forgot you have a space in the filename, so ${target} needs to be wrapped in double-qoutes.
Just to be safe, I've wrapped both the "to" and "from" for scp in double-quotes.

Code:
#!/bin/bash
zipname="dan_`date +%d-%m-%Y`.tar.gz"
source="/home/dan/temp_backups"
target="/home/dan/.gvfs/dan\ on\ servername.domain.ac.uk/backup/"
cd ${target}
[ $? -gt 0 ] && \
  {
    print "Cannot find target ${target}! Exiting!"
    return 1
    exit
  } || {
    print "Target found!"
    scp "${source}/${zipname}" "${target}" 
  }
Note that I do agree with TobiSGD about using "cp" versus "scp". Since "scp" isn't going to prompt you for authentication, you're not getting any encryption...but I didn't want to ask (just like I didn't want to ask why you have a space in a mountpoint...I mean C'mon! )
 
1 members found this post helpful.
Old 01-28-2011, 04:53 AM   #7
danubuntuman
LQ Newbie
 
Registered: Jan 2011
Location: UK
Distribution: Ubuntu 10.04 LTS
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you for your help, much appreciated! I think the double quotes around the
Quote:
$target
solved my problems!
 
  


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
File Transfer with scp,ftp and sftp disabled Question Doknik Linux - General 2 12-03-2010 04:09 AM
[SOLVED] SCP SSH automatic file transfer smithy2010 Linux - Newbie 3 05-09-2010 02:07 PM
Samba share (1gb/s) vs local ntfs-3g transfer speed renderdan Linux - Server 1 10-01-2009 06:17 AM
How to find whether file transfer has completed on scp or mysqldump. ganesh_k Linux - Newbie 7 08-06-2008 09:00 AM
cannot transfer (FTP) 10GB file, also scp dont work freebies Linux - Software 2 02-25-2005 12:38 AM


All times are GMT -5. The time now is 10:44 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration