Go Back   The macosxhints Forums > OS X Help Requests > UNIX - Newcomers



Reply
 
Thread Tools Rate Thread Display Modes
Old 01-23-2013, 08:05 AM   #1
laredotornado
Prospect
 
Join Date: Apr 2010
Posts: 35
How to execute a binary file via command line?

Hi,

I'm using Mac 10.7.5. I'm trying to write a script to conditionally launch an application, but I can't actually figure out how to launch that application. The application lives here

Code:
Daves-MacBook-Pro:~ davea$ ls -al /Users/davea/.magicJack/Softphone/magicJack.app/Contents/MacOS/magicJack 
-rwxr-xr-x  1 davea  staff  23080080 Jan 21 13:33 /Users/davea/.magicJack/Softphone/magicJack.app/Contents/MacOS/magicJack
but when I try and run the script via command line, I get an error …

Code:
Daves-MacBook-Pro:~ davea$ bash /Users/davea/.magicJack/Softphone/magicJack.app/Contents/MacOS/magicJack
/Users/davea/.magicJack/Softphone/magicJack.app/Contents/MacOS/magicJack: /Users/davea/.magicJack/Softphone/magicJack.app/Contents/MacOS/magicJack: cannot execute binary file
Anyone know the proper way to execute a binary file from the command line? Thanks, - Dave
laredotornado is offline   Reply With Quote
Old 01-23-2013, 08:50 AM   #2
jsalmi
Triple-A Player
 
Join Date: May 2008
Location: Down by the river
Posts: 190
It appears you are trying to use bash to execute a binary. Rather than:

"bash /Users/davea/.magicJack/Softphone/magicJack.app/Contents/MacOS/magicJack"

just run:

"/Users/davea/.magicJack/Softphone/magicJack.app/Contents/MacOS/magicJack"

Without the quotes, of course.

Bash will be looking for a shell script to interpret, not a binary.
jsalmi is offline   Reply With Quote
Old 01-23-2013, 11:55 AM   #3
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,940
And if you want to run this from a shell script, you could use the "system" command. Check almost any tutorial on Bash - e.g. the ones listed in the last section of this Unix FAQ
__________________
hayne.net/macosx.html
hayne is online now   Reply With Quote
Old 01-23-2013, 05:33 PM   #4
laredotornado
Prospect
 
Join Date: Apr 2010
Posts: 35
Shoot that was easy! Thanks, - Dave
laredotornado is offline   Reply With Quote
Old 01-24-2013, 09:30 AM   #5
agentx
Hall of Famer
 
Join Date: Feb 2003
Location: Brighton, UK
Posts: 3,807
And if you want it to run periodically/automatically you should use launchd
agentx is offline   Reply With Quote
Reply

Tags
binary file, command line, script

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 01:46 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.