[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'
command
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
suitable
since the new window is opened in a tab.
Eric Blake suggested using '[ "$DISPLAY" ] && open <(cat /tmp/x.html)' so that
rm
is not needed. I liked this but it failed with some error message and sleep
worked.
I'm most grateful to you all.
Barrie.
- Problem with open and rm, Barrie Stott, 2011/03/16
- Re: Problem with open and rm, Micah Cowan, 2011/03/16
- Re: Problem with open and rm, Greg Wooledge, 2011/03/16
- Re: Problem with open and rm,
Barrie Stott <=
- Re: Problem with open and rm, Ken Irving, 2011/03/16
- Re: Problem with open and rm, Eric Blake, 2011/03/16
- Re: Problem with open and rm, Bob Proulx, 2011/03/16