Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rating: Thread Rating: 6 votes, 5.00 average. Display Modes
Old 05-02-2005, 11:39 AM   #1
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
Script Menu and shell scripts

In Panther, I used a simple little shell script that removed styling from text on my clipboard:

#!/bin/sh
pbpaste | pbcopy

I stuck it in Script Menu, and it was teh awesome. Moving to Tiger, it's stopped working. I recreated the script, no change. AppleScripts work just fine.

Anyone else seeing things like this?

Addendum:

-rwxr--r-- 1 mikey admin 26 May 2 11:37 Clipboard Rinser

Looks good here.
Mikey-San is offline   Reply With Quote
Old 05-02-2005, 12:56 PM   #2
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by Mikey-San
In Panther, I used a simple little shell script that removed styling from text on my clipboard:

#!/bin/sh
pbpaste | pbcopy

I stuck it in Script Menu, and it was teh awesome. Moving to Tiger, it's stopped working.

By "stopped working" I assume you mean that, while the script does run, it no longer results in the styling being removed from text on the clipboard.

It seems to me that you were relying on buggy behaviour in earlier versions. I would have thought that 'pbpaste | pbcopy' would have zero net effect on the clipboard.
hayne is offline   Reply With Quote
Old 05-02-2005, 01:23 PM   #3
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
It works as a straight-up shell command, actually. It strips the styling right off.

Running from ScriptMenu, styling doesn't vanish. Weeeeird.
Mikey-San is offline   Reply With Quote
Old 05-02-2005, 06:56 PM   #4
Hal Itosis
Hall of Famer
 
Join Date: Apr 2002
Posts: 3,315
Quote:
Originally Posted by hayne
It seems to me that you were relying on buggy behaviour in earlier versions.

I'm not sure if by "buggy behavior" you're referring his script specifically,
or running shell scripts from the Script Menu in general. But Mikey-San's
post is right on. Executable bash scripts used to run blind (no visible 'shell')
from the Script Menu... and now they don't.

As a simple example, here's one (yet unfinished) I ran easily on Panther
to clear out recent items:
Code:
#!/bin/sh
echo 'defaults write -g AppleRecentFolders -array'
defaults write -g AppleRecentFolders -array
echo 'defaults write -g NSNavRecentPlaces -array'
defaults write -g NSNavRecentPlaces -array
cd ~/Library/Recent\ Folders/
echo 'rm -f ~/Library/Recent\ Folders/*'
rm -f ~/Library/Recent\ Folders/*
exit 0
Ignoring any possible script weaknesses... the fact is it used to work fine.
Now under Tiger, it simply won't run from the GUI (Script Menu). If I fire
up Terminal and ./ it from where it is... presto, it runs.

Apple must have killed it.
Question is: How can we get it back???

-HI-

Last edited by Hal Itosis; 05-02-2005 at 07:01 PM.
Hal Itosis is offline   Reply With Quote
Old 05-02-2005, 07:10 PM   #5
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by Hal Itosis
I'm not sure if by "buggy behavior" you're referring his script specifically

As I said:
Quote:
Originally Posted by hayne
I would have thought that 'pbpaste | pbcopy' would have zero net effect

That was why I referred to buggy behaviour.

I'm not using the Script menu so you'll have to explain more fully what you are seeing.
hayne is offline   Reply With Quote
Old 05-02-2005, 07:19 PM   #6
mark hunte
MVP
 
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
Your right, thats a pain.

I can get mine to work in terminal and textwrangeler
But not Script menu.

There has got to be answer..
mark hunte is offline   Reply With Quote
Old 05-02-2005, 07:40 PM   #7
blb
All Star
 
Join Date: Jan 2002
Location: CO, USA
Posts: 908
Quote:
Originally Posted by hayne
As I said:
"I would have thought that 'pbpaste | pbcopy' would have zero net effect"
That was why I referred to buggy behaviour.
...

Actually, first remember that an app can copy multiple formats to the [clip|paste]board when doing a copy/cut (eg, plain text, RTF, etc). pbpaste is most likely only grabbing the plain text version, then sending that back to pbcopy results in only that one format now being on the [clip|paste]board.
blb is offline   Reply With Quote
Old 05-02-2005, 08:09 PM   #8
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by blb
Actually, first remember that an app can copy multiple formats to the [clip|paste]board when doing a copy/cut (eg, plain text, RTF, etc). pbpaste is most likely only grabbing the plain text version, then sending that back to pbcopy results in only that one format now being on the [clip|paste]board.

Yes - that makes sense. I had been imagining that pbpaste would retrieve all the available formats from the clipboard. But I guess that wouldn't make sense if the only destination for that data is 'stdout'.
hayne is offline   Reply With Quote
Old 05-02-2005, 09:54 PM   #9
Mikey-San
Hall of Famer
 
Join Date: Jan 2002
Posts: 3,541
Okay, so I'm not the only one seeing this. That's both bad and reassuring at the same time. :-)

*looks for clues*
Mikey-San is offline   Reply With Quote
Old 05-03-2005, 12:07 AM   #10
Hal Itosis
Hall of Famer
 
Join Date: Apr 2002
Posts: 3,315
Exclamation Script Menu not executing shell scripts

P L E A S E !

It's too early for this topic to wander.
This is NOT an issue of formats or the
paste board server... Script Menu has
been hacked, and we want it back!!!

According to my link (2 lines above):
Quote:
The Script Menu is a system-wide utility for organizing and executing PERL, Shell, or AppleScript scripts. When activated, it displays a small script icon in the upper right of the menu bar. The contents of designated script folders is displayed as a list of script names on the menu. Selecting a menu item will execute the related script file.

Unfortunately, Tiger has stopped it from working with bash scripts.



AppleScript.scpt files still execute as they did before. (Whether this
is intentional or accidental is uncertain. Based on the quote above,
it should work. So what's the deal, and what can be done about it?).


Last edited by Hal Itosis; 05-03-2005 at 12:30 AM.
Hal Itosis is offline   Reply With Quote
Old 05-04-2005, 02:55 PM   #11
Hal Itosis
Hall of Famer
 
Join Date: Apr 2002
Posts: 3,315
Oh well. Until Apple turns the feature back on, or someone finds some
bits we can twiddle, the best soultion I've found is to use "FastScripts";
free of charge for 30 days or 100 script executions... whichever takes
longer to happen. (And $15 after that).

:^/

-HI-

Last edited by Hal Itosis; 05-04-2005 at 02:59 PM.
Hal Itosis is offline   Reply With Quote
Old 05-04-2005, 03:39 PM   #12
mark hunte
MVP
 
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
I thought I may have found a work around in Automator (Automator Library Actions -> Run Shell script) But can not get it to work.

****Edit

Okay changed it to the 'Run Applescript' action and entered this

Code:
	
	do shell script "~/downloadFind3.sh"
and saved it as a workflow in the (in this case) Safari app Script menu folder

This works for now. But not the same as just dumping the shell script in there.

Last edited by mark hunte; 05-04-2005 at 03:50 PM.
mark hunte is offline   Reply With Quote
Old 05-22-2005, 11:28 AM   #13
macmath
MVP
 
Join Date: Mar 2002
Location: Elsewhere
Posts: 1,497
Another Workaround

Shell scripts under the Script Menu can be made to work if you:
(A) Change the name from foo to foo.command
and
(B) Change the first line of the script from '#!/bin/bash' to ' #!/bin/bash'
(that is, include an opening space).
macmath is offline   Reply With Quote
Old 05-22-2005, 11:57 AM   #14
giskard22
Moderator
 
Join Date: May 2003
Posts: 4,272
Great tip, but do you have any explanation for the leading space requirement?
giskard22 is offline   Reply With Quote
Old 05-22-2005, 12:48 PM   #15
mark hunte
MVP
 
Join Date: Apr 2004
Location: Hello London Calling
Posts: 1,787
Quote:
Originally Posted by macmath
Shell scripts under the Script Menu can be made to work if you:
(A) Change the name from foo to foo.command
and
(B) Change the first line of the script from '#!/bin/bash' to ' #!/bin/bash'
(that is, include an opening space).

yes but it opens a terminal window to do this which is not ideal.

the 'do shell' works without opening a terminal window, but again this is not ideal because you have two files for one script.
mark hunte is offline   Reply With Quote
Old 05-22-2005, 02:18 PM   #16
macmath
MVP
 
Join Date: Mar 2002
Location: Elsewhere
Posts: 1,497
Quote:
Originally Posted by mark hunte
yes but it opens a terminal window to do this which is not ideal.

Arrghh!

The original scripts I tried this with naturally had an associated terminal window so I did not notice this: top with a lot of special options, opening an lftp connection to a server. That is not good at all. Back to the drawing board.

Quote:
Originally Posted by giskard22
Great tip, but do you have any explanation for the leading space requirement?

No. Some of the scripts I had under the Script Menu were old double-click .command files that I had been too lazy to convert back to ordinary shell scripts. When I created them originally, the only way I had been able to get those .command files to execute upon double-clicking was to have a leading space. I'm not sure why they need them.

Last edited by macmath; 05-22-2005 at 02:20 PM.
macmath is offline   Reply With Quote
Old 05-22-2005, 02:30 PM   #17
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
I know this is different than having the scripts in a menu, but perhaps some of you would find the contextual menu capabilities of "OnMyCommand" useful:
http://free.abracode.com/cmworkshop/
hayne is offline   Reply With Quote
Old 06-23-2005, 03:26 PM   #18
Xanders
Registered User
 
Join Date: Jun 2005
Posts: 1
What about Perl

So what about perl scripts?

The whole adding a blank space is effectively the same as removing the whole line. If you try this with a perl script it attempts to execute it as a bash script - and endless errors result.

So I'm totally screwed, I had a bunch of perl scripts that automate my daily tasks - and I came across this Tiger regression flaw while packaging them all for distibution to my coworkers. ... this is big enough for me - I might just go back to Panther. This is all so very disappointing.
Xanders is offline   Reply With Quote
Old 06-23-2005, 07:13 PM   #19
jbc
All Star
 
Join Date: Feb 2003
Location: Chico, CA
Posts: 686
Beside OMC mentioned above, Launcher enables you to use any form of file launcher you want to launch shell/perl/python/tcl scripts without causing a terminal to open. Just associate the file with Launcher, and open the script from *anywhere* to cause it to be executed.

I frequently run my scripts from Dragthing buttons using Launcher, but there are many more options for running scripts with this utility installed, which might be especially useful to those left without a Script Menu by Tiger.
jbc is offline   Reply With Quote
Old 10-08-2005, 10:13 PM   #20
afb
Triple-A Player
 
Join Date: Oct 2003
Posts: 91
I wonder if anyone has managed to fix this without using another app?
afb is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 12:17 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.