nbjahan wrote:comety, I'm here till we resolve this.
The shell script is working for me. just run it in the shell
Code: Select all
osascript -e "tell application \"LaunchBar\" to paste in frontmost application \"$(/bin/date "+%D - %r")\"" &
but if you want to write an applescript for this you should check this out:
Code: Select all
/Applications/LaunchBar.app/Contents/Resources/Actions/Paste in Frontmost Application.lbaction/Contents/Scripts/default.scpt
Code: Select all
-- Copyright (c) 2013 Objective Development
-- http://www.obdev.at/
-- Version 1
on handle_string(_string)
tell application "LaunchBar" to paste in frontmost application _string
end handle_string
and LaunchBar logs to
/var/log/system.log check the Console.app for possible errors.
nbjahan, thanks for trudging through the grey water with me

I am running tail -f /var/log/system.log and run my script, nothing was logged. Just for sanity, I have in my script the last line, of what is now a three line script, first line, shebang, second line, a call to the `date` command with some formatting strings or -flags, and the third line, a `touch /Users/me/Desktop/LaunchBar-worked-sort-of.txt`
My script is called `datey`, running it from the command line, no issue, running it from LB, and it seems to work, as that `touch` file makes it's way to the Desktop, I should put a sleep command in that after 30 seconds it removes that file, all I need is the indicator that it ran, and I can use & to toss the script into the bg to keep it from just hanging there.
Anyway, it confirms that the script is being located, is in the index, is being called, is being ran, but who knows where the stdout is going to. I know I have other scripts that do this same thing, I just can't remember them or where they are at the moment. But I used to use it all the time, when I want to put my address into a file, I would type `addy` and poof, it was on the page. This was nothing more than a bunch of echo statements and newlines.
Just pasting in your first osascript command into an open Terminal, which I am running bash, but trying to be more POSIX complaint and my shebang will call out to sh instead, though in this case, I have reverted to how I used to do things, how I know they used to work. So, paste this into a shell:
Code: Select all
osascript -e "tell application \"LaunchBar\" to paste in frontmost application \"$(/bin/date "+%D - %r")\"" &
Intesrting…After hitting return, I get output, but I get a small stall too, here is the output:
Code: Select all
me@foonty ~ $osascript -e "tell application \"LaunchBar\" to paste in frontmost application \"$(/bin/date "+%D - %r")\"" &
[3] 1271
[2] Done osascript -e "tell application \"LaunchBar\" to paste in frontmost application \"$(/bin/date "+%D - %r")\""
me@foonty ~ $08/24/14 - 01:06:23 AM
As you can see, eventually, we got the output we are looking for, yay! Not sure what the process ID's are all about, and if I keep running it, they seem to keep piling up. Are they not terminating? `jobs` lists nothing. `top`, and `ps` don't appear to show me anything though with `top` I never learned how to locate things in it unless they are using a lot of CPU, then tossing in a -u flag will nicely push it to the top of the window. In this case, I suspect there will not be enough CPU usage to gain that advantage.
Dropping the background & from your test, and it immediately returns the date formatted string.
What now? Stuff that in an AppleScript and call it a day? I hate to say it, but I'm not happy with that, it seems a kludge, and I would just you keyboard maestro to make it so there is a trigger for any time It sees the keys of "d a t e y" typed, it will run my shell script, and take the output to the cursor position, or anywhere I tell it really, and put it where it belongs. I was just trying to use LaunchBar as it seemed a nice fit, though this is getting ridiculous.
I really don't want to run this as an AppleScript, it seems an unnecessary step that should not need to be done. If the developer tells me that shell scripts can't be run directly from LaunchBar, and you must use a intermediate step to make it happen, ok, I will live with that, though that is something that I would imagine could be fixed in a dot update easily.
I may be getting a little lost in these forums, where are we at now? Running your same script in an AppleScript and then trying to call it from LB, or are we going to skip that entirely?
I just pushed the code into a file in my local actions folder, touched the parent folder to let LB know there had been a change and to re-scan the index, though I guess since I was in there I could have just updated the index, but that is the old habit I have been in.

It worked! albeit very slow. I have a command/action now called `matey` and if I run it in a shell, as in cd path/to/where/he/is then issue ./matey ( it is already chmod +x or u+x ) it will fire back the date pretty much right away. I say "pretty much" because it is not as fast as it could be, I can feel about a half a second delay, I imagine waiting for the `osascript` part to initialize.
It actually took so long on the second time, I stopped waiting, came over to this window to type my reply to you in the forum, and magically about half way through my typing, the date was injected. I just ran it again, the LB window which I keep in the upper left, just hangs there, for minutes on end, no way to back out of it, you are stuck, waiting for it to finish. I want to run option-return, though even if that works, I am getting into territory where there is too much mental overhead to doing something that is supposed to save me time, not complicate what I am up to.
What should be try next?