Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to kill Xcode by running killall Xcode.app, which works normally when I run it through terminal. However, if I put it into a bash script that I keep on my Desktop called re_xcode, the script will output the following error. Please can you tell me where I am going wrong?

No matching processes belonging to you were found

The file /Users/Max/Desktop/Applications/Xcode.app does not exist.

#!/bin/bash
killall Xcode.app
open ./Applications/Xcode.app
share|improve this question
    
-1 Two fundamental flaws in two commands leads me to believe you did not research before posting. Correct me if I'm wrong. –  Daniel Beck Jun 24 '12 at 19:55

2 Answers 2

Two mistakes:

  1. killall takes a process name as an argument. Xcode.app however is an application bundle. It contains much more than just the process, including all kinds of files that also belong to an application (graphics, translation data, et cetera).

    Thus, the actual way to kill Xcode would be:

    killall Xcode
    

    Or, in a sane way, using AppleScript:

    osascript -e 'tell app "Xcode" to quit'        
    
  2. Your other error is that . references the directory your current script resides in, which could be anything. In your case, it's the desktop. Thus, your kill command works fine, but open will fail since there's no Xcode (or "applications" folder) on your desktop.

    Xcode doesn't install to /Developer anymore. The Mac App Store version is a self-contained application under /Applications/Xcode.app. So, you could do:

    open /Applications/Xcode.app
    

    However, the most portable solution would be to just use:

    open -a Xcode
    

    This will open Xcode wherever it's installed since it relies on the LaunchServices database to figure out the correct path.


To go even further, rather than doing this as a bash script, why not create an alias in your .bash_profile? This will be much simpler to execute anywhere from your command line.

alias rex='killall Xcode && open -a Xcode'
share|improve this answer
    
You forgot the matching processed part, where the user mistakes the app bundle for the executable. killall doesn't work fine, at all. –  Daniel Beck Jun 24 '12 at 19:53
    
Oh, right. Well, killall Xcode works fine for me – but I guess a osascript -e 'tell app "Xcode" to quit' would be a more sane approach. –  slhck Jun 24 '12 at 19:56
    
Yeah, but killall Xcode.app is where the error message in the question comes from. –  Daniel Beck Jun 24 '12 at 20:03
    
True, I somehow overread that and just looked at the script. –  slhck Jun 24 '12 at 20:05

It looks like you're running that script from your Desktop, and there it can't find the path to xcode.app. Check the correct location, for me it is /Developer/Applications/Xcode.app.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.