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?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

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 Account.