Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 6, 2012, 01:19 PM   #1
Mark FX
macrumors member
 
Join Date: Nov 2011
excecuting a command line tool from Terminal

I have made a command line tool from the project template in Xcode, and have tested it from the IDE and everything is working as it should, the tool requires one argument to excecute, or if no argument is entered it simply returns the version information.

I have made an archive version with a release build. but when I navigate to the excecutable folder in Terminal, and enter the name of the app, the bash shell returns a message saying command not found.
But if I type into the Terminal window "open myAppName" it opens a second teminal window and returns the no argument version info, if I try to use "open myAppName argument" it says that the argument could not be found.
I'm using Xcode 4.52 on OSX 10.7.

Have I missed something in the way you have to build or deploy a command line tool ?

I have never built a command line tool before now, so I have no knowledge
or previous experience with this type of project.

Any help or advise would be much appreciated, Thanks in advance.

Regards Mark
Mark FX is offline   0 Reply With Quote
Old Dec 6, 2012, 02:07 PM   #2
ytk
macrumors regular
 
Join Date: Jul 2010
The "open" command is used to tell the computer to open the application as if you'd double-clicked it in the Finder. That's not really what you want to do. Instead, try invoking the program like this:

Code:
./myAppName argument
The "./" is necessary to locate the executable, because by default Bash only looks in your search path for executables, and for security reasons "." (which represents the current directory) isn't usually included in the search path.
ytk is offline   0 Reply With Quote
Old Dec 6, 2012, 02:28 PM   #3
peoplevoice
macrumors member
 
Join Date: Aug 2008
PATH environment variable

You need to add the absolute pathname of the directory where your executable is to PATH environment variable or copy your executable in one of the listed directories in the PATH environment variable.

You can type in the command line the following to see the list of current directories in the PATH environment variable: echo $PATH

To change the PATH environment variable: vi $HOME/.profile file and add at the bottom of the file the following line:

export PATH=$PATH:absolutePathnameOfDirectoryWhereYourExecutableIs
peoplevoice is offline   0 Reply With Quote
Old Dec 6, 2012, 03:46 PM   #4
Mark FX
Thread Starter
macrumors member
 
Join Date: Nov 2011
Thanks ytk & peoplevoice.

Yes adding "./" to my Terminal command did indeed run the tool.
I was aware of the $PATH variable to access system wide folders, but as a
UNIX newbie, I did not want to go down the path of changing this setting, just
to test this particular project from the Terminal.

Thanks again.

Regards Mark
Mark FX is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
better touch tool command anonymous4a Mac Applications and Mac App Store 0 Mar 11, 2014 11:38 AM
command tool for mac osx syntax.syntax OS X Mavericks (10.9) 13 Feb 14, 2014 07:09 PM
General: iOS7 command line... Equivalent of "say" command? RobertoG Jailbreaks and iOS Hacks 0 Jan 19, 2014 06:05 PM
Terminal command andynewfriends Mac Basics and Help 0 Jun 11, 2013 02:25 PM
Need command in terminal chadteetzen OS X 1 Jun 8, 2012 11:55 PM

Forum Jump

All times are GMT -5. The time now is 07:08 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC