New topic: 

shell.execute doesn't work as expected

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

         Page 1 of 1
   [ 7 posts ]                 Previous topic | Next topic          Author  
Message        hillxy          Post subject: shell.execute doesn't work as 
expectedPosted: Wed Dec 08, 2010 1:45 pm                         
Joined: Thu Sep 09, 2010 8:46 pm
Posts: 7                In my realbasic code, I need to run an application 
located somewhere under current folder, here is my code:

myShell.execute ( "open", "./folder1/folder2/myApplication.app")

But seems that it cannot find my app because it didn't do anything.

I tried that in Terminal, first go to this 'current folder', then type in open 
"./folder1/folder2/myApplication.app", it does run the app.

What could be the reason my code doesn't work?

Thanks!   
                             Top                 hillxy          Post subject: 
Re: shell.execute doesn't work as expectedPosted: Wed Dec 08, 2010 2:42 pm      
                   
Joined: Thu Sep 09, 2010 8:46 pm
Posts: 7                I changed it to:

myShell.execute ( "open", 
"./folder1/folder2/myApplication.app/Contents/MacOS/myApplication")

Still doesn't work.   
                             Top                 scarroll          Post 
subject: Re: shell.execute doesn't work as expectedPosted: Wed Dec 08, 2010 
2:50 pm                         
Joined: Sat Apr 18, 2009 9:54 pm
Posts: 23                Shell is used for commands that would normally run on 
the command line or terminal in OS X. An OS X application is actually a folder 
or 'bundle' with the real binary inside. If you want to launch a OS X 
application, the easiest way is to use the FolderItem object's launch method. 
I.e. If you have an application on your desktop called myApplication.app, you 
could do this:

Dim fiApp As FolderItem
fiApp = SpecialFolder.Desktop.Child("myApplication.app")
fiApp.Launch   
                             Top                 hillxy          Post subject: 
Re: shell.execute doesn't work as expectedPosted: Wed Dec 08, 2010 3:13 pm      
                   
Joined: Thu Sep 09, 2010 8:46 pm
Posts: 7                Thanks for your reply. Here is my code:

Dim f As FolderItem  = New FolderItem("./folder1/folder2/myApp.app")
f.Launch

Is my file path wrong? The above code builds into an application called App1. 
This is the folder structure:

Folder
  App1.app
  folder1
  folder2
    myApp.app

App1.app is two level above myApp.app   
                             Top                 hillxy          Post subject: 
Re: shell.execute doesn't work as expectedPosted: Wed Dec 08, 2010 3:14 pm      
                   
Joined: Thu Sep 09, 2010 8:46 pm
Posts: 7                Last post didn't show the folder structure I am trying 
to show. 

App1.app is at the same folder level as folder1

folder2 is subfolder of folder1, myApp.app is inside of folder2   
                             Top                 scarroll          Post 
subject: Re: shell.execute doesn't work as expectedPosted: Wed Dec 08, 2010 
3:28 pm                         
Joined: Sat Apr 18, 2009 9:54 pm
Posts: 23                Try using the child method of a folder item. Its cross 
platform and easy. The app object has a folderitem that points to itself. I.e.

App.Executable.Child("folder1").Child("folder2").Child("App2.app").Launch

Will launch an app called App2.app that is two child folders deep from the 
application folder.   
                             Top                 hillxy          Post subject: 
Re: shell.execute doesn't work as expectedPosted: Wed Dec 08, 2010 3:55 pm      
                   
Joined: Thu Sep 09, 2010 8:46 pm
Posts: 7                Thanks a lot for your help! It works now, since 
App.ExecutableFile locates in App1.app\Contents\MacOS, my code is:

App.ExecutableFile.parent.parent.parent.parent.child("folder1").child("folder2").child("App2.app")

    
                             Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 7 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to