bug-bash
[Top][All Lists]
Advanced

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

Problem with open and rm


From: Barrie Stott
Subject: Problem with open and rm
Date: Wed, 16 Mar 2011 10:54:15 +0000

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

I'm on an Imac with OS X 10.6.6. If I run the script as it stands, the open 
tries to open /tmp/$$.html in a new tab in the Safari browser and fails with 
the message: No file exists at the address “/tmp/13551.html”. The terminal 
output is the following pair of lines, which suggest that the file is still 
around after open failed:

/tmp/13551.html
/tmp/13551.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.

My two questions are: 
Why?
How can I change the script so that I can both view the file and have it 
removed?

Barrie.




reply via email to

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