New topic: 

Copy file from Shell doesn't seem to work

<http://forums.realsoftware.com/viewtopic.php?t=24882>

       Page 1 of 1
   [ 9 posts ]                 Previous topic | Next topic         Author  
Message       brianheibert.com           Post subject: Copy file from Shell 
doesn't seem to workPosted: Mon Oct 20, 2008 2:04 pm                            
   
Joined: Thu Jan 25, 2007 7:38 pm
Posts: 371
Location: Loveland, OH USA              Copying files from the shell command 
doesn't seem to work for some reason
I enter the full path in my original file edit field and my duplicate file edit 
field
and nothing happens.

Is it possible to use a AppleScript to do this?
If so how would I do that?

But anyway here's my shell code
Code:
dim original as string
dim copy as string

dim sysversion as integer
dim myOSErr as Boolean
myOSErr =system.gestalt("sysv",sysversion)

original = CopyMate.OrigFilePath.text
copy = CopyMate.DuplicateFilePath.text


If TargetMacOS and sysversion >1040 then
  dim copyshell as shell
  copyshell = new Shell
  copyshell.execute "cp "+original+" "+copy
else
  MSGBOX "CopyMate requires MacOS X (v10.4.x or higher)."
  quit
end if


  
Brian   
                            Top                mrebar           Post subject: 
Re: Copy file from Shell doesn't seem to workPosted: Mon Oct 20, 2008 2:44 pm   
                     
Joined: Wed Feb 15, 2006 1:30 pm
Posts: 2229
Location: U.S.A (often) Spokane, Eugene, Pago Pago              Quote:I enter 
the full path in my original file edit field
Choose a file to test with. Open the Terminal application. Toss that file on 
the Terminal window. Is the path the same as the one you describe above?

Michael   
                            Top               brianheibert.com           Post 
subject: Re: Copy file from Shell doesn't seem to workPosted: Mon Oct 20, 2008 
2:58 pm                               
Joined: Thu Jan 25, 2007 7:38 pm
Posts: 371
Location: Loveland, OH USA              it is sort of the same except that in 
RB the path is separated by : 
and in the terminal the path is separated by /

It looks like it did make a copy though because when I ran the terminal I found
gobarbg401.pct

and the file was originally 
gobarbg400.pct

So I guess I am ok

Is there anyway to display a MSGBOX with the file path to the copied file?
So I can confirm to the user that the file was copied?

Brian     
_________________
Brian Heibert
http://www.brianheibert.net
[EMAIL PROTECTED]  
                            Top                brianheibert.com           Post 
subject: Re: Copy file from Shell doesn't seem to workPosted: Mon Oct 20, 2008 
3:06 pm                               
Joined: Thu Jan 25, 2007 7:38 pm
Posts: 371
Location: Loveland, OH USA              I just tested it again with the new 
file path MSGBOX's

Code:
dim copyshell as shell
copyshell = new Shell
copyshell.execute "cp "+original+" "+copy
MSGBOX "File: "+original+ "copied as: "+copy



It says it copied it
but I can't find the copied file.

I tried to copy this file: Macintosh 
HD:Users:brianheibert:Documents:LtrToMeara.pages:
to Macintosh HD:Users:brianheibert:Documents:LetterToMeara.pages:
But I did a Spotlight search on LetterToMeara and it couldn't find anything
Is the end : a problem?  I didn't put that there it was automatically put by 
the program.     
_________________
Brian Heibert
http://www.brianheibert.net
[EMAIL PROTECTED]  
                            Top                Mo_Funds           Post subject: 
Re: Copy file from Shell doesn't seem to workPosted: Mon Oct 20, 2008 3:52 pm   
                            
Joined: Fri Sep 30, 2005 3:29 pm
Posts: 387              Make sure you have the correct permissions for each 
directory and the file(s) itself.

You may also want to use cp via terminal first to make sure you know how to 
correctly copy the file where you want it and that it does indeed work 
properly.   
                            Top               kendoll           Post subject: 
Re: Copy file from Shell doesn't seem to workPosted: Mon Oct 20, 2008 5:02 pm   
                            
Joined: Mon Jul 17, 2006 10:39 am
Posts: 1154              When using a shell on Mac OS X, you are essentially 
patching into the Unix subsystem.  Unix file paths usually do NOT match up with 
classic Mac OS paths.

I'd recommend getting a FolderItem reference to the source and destination 
files, then passing each of the FolderItem.ShellPath to cp.  That will not only 
allow you to do better error checking on your end, but also ensure the paths 
are valid and escaped properly.

Also, you may want to look into using ditto, as cp will not preserve resource 
forks.     
_________________
Kenneth McCleary
UPshift Studios
http://ken.upshiftstudios.com/  
                            Top               brianheibert.com           Post 
subject: Re: Copy file from Shell doesn't seem to workPosted: Mon Oct 20, 2008 
5:59 pm                               
Joined: Thu Jan 25, 2007 7:38 pm
Posts: 371
Location: Loveland, OH USA              I got a problem:
Code, CPMModule.FileOperations.Copy, line 10, Type mismatch error.  Expected 
FolderItem, but got String., origc = CopyMate.OrigFilePath.text
it is saying Expected folderitem but got string on origc and copyc
I need a path to be put in two edit fields one is OrigFilePath.text and the 
other is DuplicateFilePath.text
that is why it is string but I can see that for the origc.ShellPath and 
copyc.ShellPath to work it needs to be folderitem
What should I do?

Code:
dim original as string
dim copy as string

dim sysversion as integer
dim myOSErr as Boolean
myOSErr =system.gestalt("sysv",sysversion)

dim origc as folderitem
dim copyc as folderitem
origc = CopyMate.OrigFilePath.text
copyc = CopyMate.DuplicateFilePath.text

original = origc.ShellPath
copy = copyc.shellPath


if original = "" and copy = "" or original = "" or copy  = "" then
  MSGBOX "No file path found. Please re-enter a original file path and a copy 
file path. Then try again."
  Exit
end if

If TargetMacOS and sysversion >1040 then
  dim copyshell as shell
  copyshell = new Shell
  copyshell.execute "ditto "+original+" "+copy
  MSGBOX "File: "+original+ " copied as: "+copy
else
  MSGBOX "CopyMate requires MacOS X (v10.4.x or higher)."
  quit
end if

     
_________________
Brian Heibert
http://www.brianheibert.net
[EMAIL PROTECTED]  
                            Top                timhare           Post subject: 
Re: Copy file from Shell doesn't seem to workPosted: Mon Oct 20, 2008 6:41 pm   
                     
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 3565
Location: Portland, OR  USA              Use GetFolderItem to return a 
folderitem from a path.
Code:origc = GetFolderItem(CopyMate.OrigFilePath.text)
copyc = GetFolderItem(CopyMate.DuplicateFilePath.text)


Tim   
                            Top               brianheibert.com           Post 
subject: Re: Copy file from Shell doesn't seem to workPosted: Mon Oct 20, 2008 
7:04 pm                               
Joined: Thu Jan 25, 2007 7:38 pm
Posts: 371
Location: Loveland, OH USA              Thankyou that worked.

Brian     
_________________
Brian Heibert
http://www.brianheibert.net
[EMAIL PROTECTED]  
                            Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 9 posts ]     

-- 
Over 900 classes with 18000 functions in one REALbasic plug-in. 
The Monkeybread Software Realbasic Plugin v8.1. 

&lt;http://www.monkeybreadsoftware.de/realbasic/plugins.shtml&gt;

[email protected]

Reply via email to