Reputation: 461
In my bash script i have:
program=*program_name*
condition=$(which $program 2>/dev/null | grep -v "not found" | wc -l)
if [ $condition -eq 0 ] ; then
echo "$program is not installed";
echo -n *mypass* |sudo -S gem install $program;
fi
First of all, it installs program every time. It shows that program is not installed, but i can use it from terminal.
...then, i need to use this program in my cocoa application, for example
program --help
Using
system([pathToFile UTF8String]);
i get:
path_to_bundle/myBashScript.sh: Permission denied // Where path is in bundle
path_to_folder/myBashScript.sh:line 30: program: command not found // Where path is from other system folder
Using NSTask
i get program: command not found
every time.
I don't understand why this is happening. And i would like to know how i can use this program in my cocoa app.
Upvotes: 2
Views: 119
Reputation: 461
So, i have found the solution.
When you're trying to run the custom system program from the cocoa app, you should give the full path to the binary.
The problem is in:
program=*program_name*
*program_name*
should be full path to binary, in my case it was /Library/Ruby/Gems/2.0.0/gems/program-version/bin/program
For additional information about installation paths: https://wiki.haskell.org/Mac_OS_X_Common_Installation_Paths http://help.rubygems.org/discussions/problems/739-how-to-run-applications-installed-by-gem
Upvotes: 1