Problem executing a shell script

General discussions about LaunchBar
Post Reply
tanc00
Posts: 2
Joined: Sun Dec 23, 2007 2:53 am

Problem executing a shell script

Post by tanc00 » Sun Dec 23, 2007 3:03 am

Hi, I'm testing out LaunchBar as a replacement for Quicksilver and am having some trouble just executing a shell script which executed just fine in Quicksilver.

The script is called flushdns.sh and is located in the ~/Library/Scripts folder which is being searched by LaunchBar.

The contents of the script are simply:

Code: Select all

#!/bin/sh

# Flush the DNS cache
dscacheutil -flushcache


The script is executable (chmod +x) and executes fine in the terminal but is not showing up in LaunchBar.

The files creator and type have been emptied:

Code: Select all

$ GetFileInfo flushdns.sh 
file: "/Users/me/Library/Scripts/flushdns.sh"
type: ""
creator: ""
attributes: avbstclinmedz
created: 12/23/2007 11:29:48
modified: 12/23/2007 11:29:48


I've attempted to create a new script in nano but that has the same result. If I force Launchbar to pick up the file in the Unix Executables Indexing Rule by adding it manually it shows up as a Plain Text File and opens in the default editor for those files.

Am I missing something obvious or is my computer messed up? Or has Launchbar got a serious bug with executable files?

I'm using LaunchBar 4.3.3 (v547). Any help would be appreciated.

ludwigschubert
Rank 4
Rank 4
Posts: 285
Joined: Fri Jun 29, 2007 5:54 pm
Location: Germany, Bavaria

Post by ludwigschubert » Sun Dec 23, 2007 4:21 am

Hi tanc00!
I've been trying this out for myself with your code.

Code: Select all

#!/bin/sh 

# Flush the DNS cache
dscacheutil -flushcache


Since everything (execution and indexing) works flawlessly for me, I'll outline what I've done to achieve that -
although I think you probably know this stuff ten million times better than me(never worked with shell scripts before), maybe you're just missing a detail. :D

I followed the ionstructions given in LaunchBar's Help:
LaunchBar must be able to distinguish a Shell Script from an ordinary plain text file. First, make sure that your script contains a proper shebang line:

Code: Select all

#!/usr/bin/ruby
puts 'Hello world'

Further, the script must have execute permissions set to make LaunchBar recognize it as a Unix Executable:

Code: Select all

chmod +x MyHelloWorldScript


So I copied the code into textEdit, saved the file as Test (because I couldn't get it to work with an extension (might be normal, dunno))
on my harddisk, told LaunchBar to index the contents of the folder that contained the 'unix executable' as finder called it.
If I double-click it in finder, execute it via the Terminal or launch it in LaunchBar, it always works.
However, I didn't get it to work with that extension - you might want to try to remove it. It should work.

Without the extension even Finder recognizes the file as a Unix executable, see the pics below:
With extension .sh:
Image
Without the extension:
Image

btw: I'm glad to see 'real' Unix users work with LaunchBar, too ;-)

Sincerely,
Ludwig :D

tanc00
Posts: 2
Joined: Sun Dec 23, 2007 2:53 am

Post by tanc00 » Sun Dec 23, 2007 4:32 am

Hi Ludwig, your suggestion of removing the extension worked great. I don't know why LaunchBar can't figure out what file it is with the extension, .sh is a normal extension for shell scripts. Maybe I'll email the developer to see if he can shed some light on it.

Thanks for your help. :)

ludwigschubert
Rank 4
Rank 4
Posts: 285
Joined: Fri Jun 29, 2007 5:54 pm
Location: Germany, Bavaria

Post by ludwigschubert » Sun Dec 23, 2007 4:41 am

tanc00, you're welcome.

Don't hesitate to contact Objective Development. Although they are quite busy, they usually respond very well to feature suggestions or bug reports - especially if they're as concise as this one.

sincerely,
Ludwig

Post Reply