Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rating: Thread Rating: 7 votes, 5.00 average. Display Modes
Old 02-23-2002, 10:03 AM   #1
fab
Prospect
 
Join Date: Feb 2002
Location: Netherlands
Posts: 17
Question EXACT copy from remote server to local?

A couple of months ago I created a website with some Perl scripting.
I was able to finetune and test my scripts locally with MacPerl on OS 9, even with some added .pm modules.

But now on OSX, I can't get it to work... I suspect there are some problems with filepermissions etc. but as a newby, I was wondering if it was at all possible to copy all files, INCLUDING file permissions, from the remote webserver to a local folder on my machine.

Also, are there any tips on how to set the path references correctly? somehow I didn't even get relative paths working...
like on the webserver:
use lib "/home/users44/sarcle/mybin";

(btw I put my extra Perl modules in that directory)

to a local version of the same structure.

Thanx a bunch!
fab is offline   Reply With Quote
Old 02-23-2002, 11:18 AM   #2
moyashi
Triple-A Player
 
Join Date: Jan 2002
Location: Sapporo
Posts: 66
not a perl scrippter but ... a friend was mentioning that net:ftp might work (we're trying to figure out a cheap way to backup hosting accounts without getting a tape drive.)

... how to do it is wayyy beyond me.
__________________
I'm just a rock in the river
moyashi is offline   Reply With Quote
Old 02-23-2002, 12:39 PM   #3
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
can you create a tarball on the remote server?
mervTormel is offline   Reply With Quote
Old 02-23-2002, 12:44 PM   #4
fab
Prospect
 
Join Date: Feb 2002
Location: Netherlands
Posts: 17
Tarball?

If I'm correct, you mean a .tar archive, made on the server itself.
Does this copy all file permissions etc. into the archive?

Also, how do I create (or expand for that matter) a tarball using the tcsh?

Thanks
fab is offline   Reply With Quote
Old 02-23-2002, 01:40 PM   #5
pmccann
Major Leaguer
 
Join Date: Jan 2002
Location: Adelaide, South Australia
Posts: 470
[Stealing from myself again! There's an answer to your question hiding amidst this lot.]

If you're simply looking at creating archives from extant directories you can use one of the following prescriptions. Move to the directory that contains the thing you want to tar up: suppose it's a directory "inputdir" in your home directory. Then either use

% cd
% tar cf output.tar inputdir

or, if you'd like the output file to be already compressed, use the "z" flag:

% cd
% tar zcf output.tar.gz inputdir

The latter produces a tarred and compressed version of inputdir. If you're only looking to copy this directory somewhere else on your hard drive --say to the directory "/Users/someone/archive/stuff" -- and to preserve the permissions on the files in the directories, use something like

% tar cpf - inputdir | (cd /Users/someone/archive/stuff; tar xpf -)

You will, of course, need to have write access to that directory in order to create the "new" inputdir inside of it. If you don't want to organise for the change of permissions required to do this then just use "sudo":

% sudo tcsh
Password: .....
# tar cpf - inputdir|(cd /Users/someone/archive/stuff; tar xpf -)
# exit

[[Note: you could also try

# cp -R sourcedir destdir

if the contents of the directory are nice straightforward files and you don't really care about the permissions on the files. Preserving permissions is probably the best reason to use tar if you want to copy directory trees from place to place.]]

Finally, and perhaps most usefully for what you've described above: if you want to copy a directory tree from one machine to another using a secure protocol (and both machines are set up with secure shell), and also wish to preserve ownership of the files in question you can use:

%tar cpf - inputdir|(ssh new.machine.address "cd /my/destination; tar xpf -")

Note that I'm assuming your username on both machines is identical. If not you'll need to include a "-l username" piece in the ssh command.

If this is too daunting you can just make your .tar.gz file from the directory as given above, scp this single file to your machine, move the file to where you want the thing expanded and enter "tar zxpf output.tar.gz".

That should get you started, and --with any luck-- finished.

If I've missed your particular tree in the forest grown above then let me know what you're trying to do and how your attempting to do it. If anyone else wants to correct, clarify or add to what's above please jump in!

Oh yeah: if your perl scripts are giving you grief there's a few things to watch for... (1) the first line of each must read "#!/usr/bin/perl", with possibly some extra flags after that, (2) line endings *must* be unix (this may well be your problem); to convert "my_mac_file.pl" to unix line endings you can use

% perl -pi -e 'tr/\015/\012/' my_mac_file.pl

Bingo: that's it! (3) You might have to give a bit more info about the paths that you're trying to get working. If you've installed the modules on your own machine are they in the standard place (ie /Library/Perl/* )? If they are then you'll not need to do anything special (ie you won't need to have a "use lib" statement at all). If not, just go to the directory in which you've installed them and enter:

% pwd

then "use lib ...." in your scripts, where .... is the output from the pwd command.

Cheers,
Paul
pmccann is offline   Reply With Quote
Old 02-23-2002, 01:41 PM   #6
mervTormel
League Commissioner
 
Join Date: Jan 2002
Posts: 5,536
--
If I'm correct, you mean a .tar archive, made on the server itself.
Does this copy all file permissions etc. into the archive?
--

correct. yes, the -p switch to tar asks to keep file permissions. you may have owner:group issues on the files, tho.

e.g., create tar file foo.tar, keep permissions, gzip files

% tar -cpfz foo.tar.gz /pathto/target

you might want to practice tar'ing and untar'ing some local file sandbox so you get the feel of tar; especially the untar part

http://www.gnu.org/manual/tar-1.12/h...e/tar_toc.html

but, you might ask your hoster what's the best way to do this. space may be prohibitive, tar may work differently, etc.
mervTormel is offline   Reply With Quote
Old 02-24-2002, 04:14 AM   #7
fab
Prospect
 
Join Date: Feb 2002
Location: Netherlands
Posts: 17
Talking It worked!! (for the most part) THANX

Creating a .tar file and expanding it locally did the trick wonderfully.
Also the tip of using pwd to find where files really are, helped a lot.

The Perl script runs like a charm...but somehow relative path references to some data files insist on their absolute counterparts...
like:
$data_file_path= "../data/data.txt";

need to be:
$data_file_path= "/Users/fabien/home/users44/sarcle/www/data/data.txt";

as all files are in the same place, I can't imagine how things should be different now.

THANX to all who replied!!

*GREAT*

Fabien
fab is offline   Reply With Quote
Reply


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

Forum Jump



All times are GMT -5. The time now is 05:35 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.