[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with open and rm

From: Barrie Stott
Subject: Re: Problem with open and rm
Date: Thu, 17 Mar 2011 07:55:50 +0000

On 16 Mar 2011, at 18:42, Greg Wooledge wrote:

> On Wed, Mar 16, 2011 at 10:54:15AM +0000, Barrie Stott wrote:
>> The script that follows is a cut down version of one that came from 
>> elsewhere.
>> #!/bin/bash
>> cp /tmp/x.html /tmp/$$.html
>> ls /tmp/$$.html
>> [ "$DISPLAY" ] && open /tmp/$$.html
>> ls /tmp/$$.html
>> rm -f /tmp/$$.html
>> If I comment out the final 'rm' line and run it again, I get what I want
>> displayed (and a similar pair of lines on the terminal) but unfortunately the
>> temporary file is left lying around.
> As a cheap workaround, you can just delay the rm a bit.  Add a sleep
> command before it.

Many thanks to Greg and the others who replied. I've now added a 'sleep 2' 
and everything works as I want.

> A proper fix would be for open to allow you some means of finding out
> when it has, in fact, "opened" the target, so that you know when it's
> safe to remove it.  I doubt you'll be able to do that, but hey, maybe
> I'm wrong.

Bob Proulx also suggested finding out more about open and using the -W option.
Unfortunately, -W causes open to wait until Safari closes down and is not 
since the new window is opened in a tab.

Eric Blake suggested using '[ "$DISPLAY" ] && open <(cat /tmp/x.html)' so that 
is not needed. I liked this but it failed with some error message and sleep 

I'm most grateful to you all.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]