D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Another Scrip Problem

 

> However I do not think it is very elegant, and I do not like putting
> temp  files on other peoples machines.

You'd be better off using something like /tmp/$PID as a temp file too.
As written your script can do strange things if you have more than one
concurrent invocation.

It's getting a little bit off topic, because as another poster pointed out, you can do this without creating a temp file at all (and it's better to do it that way). Having said that, if you are going to be writing a script that creates a temp file, you really should use the mktemp utility. The man page has a lot of info on how to use it, but in the simple case it's:

TMPFILE='mktemp /tmp/example.XXXXXXXXXX'
echo "program output" >> $TMPFILE
-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html