Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to execute a shell command in Xcode?

Since I started programming in Xcode, I`m trying to keep me busy with new challenges.

Now I'm trying to figure out how to run a shell command (e.g.: logname) from an Xcode application. Yes I want to mix a shell command with Objective-C syntax.

I know this is possible with Applescripts.

Is it possible to do it with Xcode?

Thanks.

Mac Mini, Mac OS X (10.4.3)

Posted on Jun 14, 2006 1:21 PM

Reply
2 replies

Jun 14, 2006 1:40 PM in response to MartinPerilli

Let me give you a larger image of what I intend to do.

I need to know which user is logged to a Mac while my application is running. My first idea was to run a shell command such as logname. But I haven't found a solution to build a Cocoa project with shell commands in it. (Still looking for an answer to this)

Then I thought that I could build an Applescript project to execute:
<pre>
do shell script "logname"
</pre>
and open my Cocoa application with a parameter (yes the username logged to the mac would be the parameter:
<pre>
tell application "Finder" to open file "cocoa-application" of folder "application"
</pre>
But I still don't know how to call my cocoa application with a parameter. Nor how to take in a parameter from the same application.

Any ideas?
Someone?
AnyOne?

How to execute a shell command in Xcode?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.