Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Copy remote files with resource forks Network
I wanted to copy an OS 9 application folder from a remote machine to my local one, given that I only had Remote Login access to the far computer.

Since the application and its files had resource forks, this limited my choices. Here's what worked:
  1. Turn on File Sharing on the local computer
  2. ssh to remote
  3. remotely mount the afp volume you just shared
  4. copy files to the afp volume using ditto
  5. unmount the afp volume
  6. exit ssh, and
  7. turn off local File Sharing.
Read on to see how to do steps 2-6...

ssh -2 -l remoteUserName remote.wherever.com
sudo mkdir /afptemp
# Can be anything instead of afptemp, but needs to be in root directory

sudo mount_afp afp://user:password@111.111.111.111/user /afptemp
# Substitute your local IP address for 111.111.111.111

sudo ditto -V -rsrcFork remoteFolder /afptemp/localFolder
# -V is nice to see progress as each file is copied

sudo umount /afptemp
exit
Thanks to Mount AFP volumes from the terminal by dreness, and for ditto info, Easy and complete folder backups by robg.

Other approaches I tried that didn't work: Some popular methods like secure copy (scp, which the fine program RBrowser uses) don't copy resource forks. And I tried both iDisk (which is resource-fork friendly) and Disk Image (which can contain files with resource forks inside, yet doesn't need a resource fork itself) approaches, but both were problematic.Additional reading:

    •    
  • Currently 3.00 / 5
  You rated: 4 / 5 (4 votes cast)
 
[9,943 views]  

Copy remote files with resource forks | 12 comments | Create New Account
Click here to return to the 'Copy remote files with resource forks' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Alternate approaches
Authored by: sabi on Mar 13, '02 03:50:20AM
sudo mkdir /afptemp

# Can be anything instead of afptemp, but needs to be in root directory


Why be root? You can create a mount point anywhere you want.

And I tried both iDisk (which is resource-fork friendly) and Disk Image (which can contain files with resource forks inside, yet doesn't need a resource fork itself) approaches, but both were problematic

I'd be interested to know what was problematic about them, since I've used both successfully. Here's an example of copying BBEdit to my iDisk and back:

% mkdir iDisk

% mount_afp afp://njriley:password@idisk.mac.com/njriley iDisk
% launch -f ~apps/Applications/BBEdit 6.5.2/BBEdit
/Volumes/GrayApps/Applications/BBEdit 6.5.2/BBEdit: scriptable Mac OS X application [Carbon, prefers native OS X]
type: 'APPL' creator: 'R*ch'
[can't access CFBundle for application]
kind: Application
data fork size: 4.47 MB on disk (4683709 bytes used)
rsrc fork size: 1.90 MB on disk (1989554 bytes used)
created: 10/11/01 8:04:53 AM
modified: 1/24/02 12:00:24 PM
accessed: 3/13/02 1:20:18 AM [only updated by Mac OS X]
% ditto -rsrc ~apps/Applications/BBEdit 6.5.2/BBEdit iDisk/Documents/
% launch -f iDisk/Documents/BBEdit
iDisk/Documents/BBEdit: scriptable Mac OS X application [Carbon, prefers native OS X]
type: 'APPL' creator: 'R*ch'
[can't access CFBundle for application]
kind: Application
data fork size: 4.47 MB on disk (4683709 bytes used)
rsrc fork size: 1.90 MB on disk (1989554 bytes used)
created: 10/11/01 5:04:53 AM
modified: 1/24/02 12:00:24 PM
accessed: 1/24/02 12:00:24 PM [only updated by Mac OS X]
% ditto -rsrc iDisk/Documents/BBEdit /tmp
% launch -f /tmp/BBEdit
/tmp/BBEdit: scriptable Mac OS X application [Carbon, prefers native OS X]
type: 'APPL' creator: 'R*ch'
[can't access CFBundle for application]
kind: Application
data fork size: 4.47 MB on disk (4683709 bytes used)
rsrc fork size: 1.90 MB on disk (1989554 bytes used)
created: 10/11/01 5:04:53 AM
modified: 1/24/02 12:00:24 PM
accessed: 1/24/02 12:00:24 PM [only updated by Mac OS X]
% umount iDIsk


As you can see, the resource fork was preserved, so were the type and creator, even the creation/modification dates.

[ Reply to This | # ]
Alternate approaches
Authored by: brettc on Mar 13, '02 09:58:01AM
These are excellent tips, however I'm trying to take this approach yet allow backups to only copy changed files, so if I run this command as above, only changed items from a 20GB set of files are copied every evening at 2AM or something. It doesn't seem very efficient to copy everything every time. "rsync" does this with the command listed below, however the resource forks aren't retained. Anyone have an idea of how to get the functionality of both of these in one command. I would think Apple would have updated ditto with this sync or backup functionality by now, but it's still dated 1994 when you do a "man" on it! This works, but copies the whole set every time: sudo ditto -v -rsrcFork '/Volumes/MacintoshHD/Desktop Folder/Projects/' '/backup/Projects/' This is nice, but doesn't get the resource forks: rsync -av --delete '/Volumes/Macintosh HD/Desktop Folder/Projects/' '/backup/Projects/'

Thanks for any feedback! I could probably install someone else's copy tool in unix perhaps, I was just hoping something might already be built in.

[ Reply to This | # ]
Alternate approaches
Authored by: sabi on Mar 13, '02 05:06:33PM
Ditto doesn't do syncing. There are some Perl modules that do, though, and a command-line rsync-a-like (psync).
psync   [-d][-n][-q|-v] source_items ... target_directory
psync -r[-d][-n][-q|-v] source_directory target_directory
If you have Fink, just install 'macosx-file-pm' and you'll get psync. Fink's info says:
macosx-file-pm-0.61-1: A collection of modules to manipulate files on MacOS X.


[ Reply to This | # ]
RsyncX -- rsync with HFS+ support
Authored by: sjk on Mar 16, '02 03:04:36PM
Alternate approaches
Authored by: danwan on Mar 13, '02 10:50:38PM
iDisk/ditto problem details

Ditto to my AFP share works fine.

But ditto to iDisk had a file name too long problem:

danwan% ditto -V -rsrcFork /Applications/BBEdit Lite 6.1 /Users/danwan/idisktemp/Documents/BB

>>> Copying /Applications/BBEdit Lite 6.1
copying file ./BBEdit Lite 6.1 ... /Users/danwan/idisktemp/Documents/BB/BBEdit Lite 6.1.__XXCOPIERXX__.810.0: File name too long
/Users/danwan/idisktemp/Documents/BB/BBEdit Lite 6.1: File name too long


So ditto-ing the whole folder to iDisk didn't work. But ditto-ing the OS9 and the OSX apps individually to iDisk did work:

danwan% cd /Applications/BBEdit Lite 6.1


danwan% ditto -V -rsrcFork BBEdit Lite 6.1 for OS 9 /Users/danwan/idisktemp/Documents/BBos9app
>>> Copying BBEdit Lite 6.1 for OS 9
copying file ./BBEdit Lite 6.1 for OS 9 ... 2409200 bytes

danwan% ditto -V -rsrcFork BBEdit Lite 6.1 /Users/danwan/idisktemp/Documents/BBosXapp
>>> Copying BBEdit Lite 6.1
copying file ./BBEdit Lite 6.1 ... 2268268 bytes


[ Reply to This | # ]
Alternate approaches:Or the unix way
Authored by: aaron on Mar 13, '02 11:27:54PM

There's always the secure, gzipped transfer:
ssh remotehost 'tar czf - FileName' | tar xzf -

I usually alias this to netcp or something



[ Reply to This | # ]
Alternate approaches:Or the unix way
Authored by: sjk on Mar 16, '02 03:09:36PM
launch?
Authored by: aiBoek on Mar 14, '02 06:12:12PM

What's this launch command? I don't seem to have it on my computer, though I do have DevTools installed.

Thanks for the great tip, though!



[ Reply to This | # ]
rBrowser 3.05
Authored by: russh on Mar 14, '02 06:49:50PM
I'm no expert, but I believe it is possible to maintain the resource forks with rBrowser. See: http://www.rbrowser.com/MacOSIssues.html

To the point of the original post, it is possible with rBrowser 3.05 to open and edit files on the remote host.

For instance, if you had a Word document on the remote host you could ssh to the remote box, double click the Word foo.doc in rBrowser, open it on your local machine and edit away. When you save, rBrowser automatically saves the changes to the remote box. (This assumes you have a copy of Word on the local box.)

I don't know if this is a new feature, but I think it's pretty cool to be able to do this with ssh.

[ Reply to This | # ]
AppleTalk mounts
Authored by: Hes Nikke on Mar 16, '02 05:49:57AM
wile working on a differnt tip (to be submitted later) i found that you can: a) mount without sudo b) mout apple talk volumes with
%mount_afp afp:/at/name:password@ServerName/Share ~/afptemp
i also found that the finder does some realy screwy things if you mount to a folder that was already there. if you click on that folder (wich has magicly turned into an alias!) it complains about not beaing able to find the thing about %50 of the time! also any aliases that point into said folder brake and wind up pointing to aparently random locations in your file system. lastly symbolic lings that point into said folder don't work at all within the finder :-/ after i unmount other stange things happen, some times the folder (wich is now back to a folder!) some times is back to normal and some times points to an aparently random location in your file system untill you rename said folder!! basicly, the Mac OS X finder doesn't quite like this cool unixism....

[ Reply to This | # ]
resetting AppleTalk mounts
Authored by: dhed on May 16, '02 07:53:25PM

After running the command outlined above, I found that everytime I go to mount the volume, it appears listed in /Volumes, but I can't see it in the Finder. And this is after using the Finder to mount it! I have to umount and then rm the remaining directory to get rid of it too. I really don't want to have to go through all the trouble of running Terminal commands to just puruse an AppleTalk volume. Is there any way to set this back to the way it was? I have looked all over for some pref to delete...



[ Reply to This | # ]
resetting AppleTalk mounts
Authored by: dhed on May 17, '02 02:41:24PM

Hated to do it, but I restarted and the mount point problem went away. :-(



[ Reply to This | # ]