Register
It is currently Fri Aug 01, 2014 10:30 pm

Move home folder to server


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Thu Dec 17, 2009 1:53 pm   

Joined: Thu Dec 17, 2009 1:43 pm
Posts: 1
Hi

I have searched all through google looking for what I thought should be quite a basic script and I am struggling. Basically we would like to copy a users home folder to a server so that we can then copy that on to their new Mac.

So far, I have got this working... cp -Rfvp /path/to/source /path/to/destination this works ok for folders within the home folder such as Document and Desktop but not for the actual Home folder itself, it seems to try to copy my trash can and then crash. I have also tried to put multiple copies into the same script but I don't think I have the syntax correct...

Example

cp -Rfvp /path/to/source/Desktop /path/to/destination
/path/to/source/Documents /path/to/destination
/path/to/source/Movies /path/to/destination

How do I put more than one move into the script?

Lastly... would something like this work?

#! /bin/bash
echo -n "Enter Home folder name"
read -e HOME
setterm -background $HOME
cp -Rfvp /path/to/source/users/$home/Desktop /path/to/destination/$HOME

I'm not very good at this but I have really tried to figure this out on my own, any help would be appreciated!

Mike


Top
 Profile  
 PostPosted: Thu Dec 17, 2009 2:33 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 534
That's the idea, except

- setterm command is useless: it surely does not what you think
- don't mix lowercase and uppercase in commands and variables : $home is not $HOME
- if you have spaces in $HOME variable, use more quotes

If you have error messages, or the script does not what you want, please be precise.

friendly.


Top
 Profile  
 PostPosted: Fri Dec 18, 2009 2:30 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
Watael wrote:
- if you have spaces in $HOME variable, use more quotes

Actually not entirely true. Setting the variable "manually" like this will require quoting:
Code:
#!/bin/bash
# Does not work
var=this is a spaced string
# Works
var="this is a spaced string"


Using read this is not an issue, the input to read is directly put into the variable.
Code:
sajko@hanna:~> cat a.sh
#!/bin/bash
# -p "Input: " will only print "Input: "
read -p "Input: " var
echo "Output: $var"
sajko@hanna:~> bash a.sh
Input: Testing with spaces     alot of them ;)
Output: Testing with spaces     alot of them ;)


Best regards
Fredrik Eriksson


Top
 Profile  
 PostPosted: Thu Dec 24, 2009 7:06 pm   

Joined: Thu Oct 16, 2008 3:05 pm
Posts: 13
Try scp -r <directory name> <servername>:<directory> something like:

SERVER = 'servername'
echo "Directory name: "
D = read userdir

scp -r $D $SERVER:<new home directory>


or something like that...good luck! :)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP