On 30Oct2011 17:35, Tim Johnson <t...@akwebsoft.com> wrote: | * Cameron Simpson <c...@zip.com.au> [111030 13:12]: | > Should do. The open-an-app mechanism is the same. | > | > However, as written withstdin leaves the temp copy lying around (the | > --keep mode). For HTML this won't waste much disc space by video will | > quickly get wasteful. I intend adding a --keep=N option to tidy up the | > temp file after N seconds, time for the app to open the file before | > tidyup. | Looking forward to it.
Try the attached version. Use --keepfor=60 (or similar), not --keep. Cheers, -- Cameron Simpson <c...@zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/ If you cannot, in the long run, tell everyone what you have been doing, your doing has been worthless. - Erwin Schrodinger
#!/bin/sh # # Copy stdin to a temp file, then pass as arg to a command expecting a filename. # - Cameron Simpson <c...@zip.com.au> 14jul2004 # set -ue : ${TMPDIR:=/tmp} keep= cleanafter= ext= cmd=$0 usage="Usage: $cmd [{--keepfor=seconds|--keep}] [--ext=.blah] command [args...]" badopts= while [ $# -gt 0 ] do case $1 in --keepfor) keep=1 cleanafter=$2 shift ;; --keepfor=[1-9]*) keep=1 cleanafter=`expr "x$1" : 'x--keepfor=\(.*\)'` ;; --keep) keep=1 ;; --ext) ext=$2; shift ;; --ext=*) ext=`expr "x$1" : 'x--ext=\(.*\)'` ;; --) shift; break ;; -?*) echo "$cmd: unrecognised option: $1" >&2 badopts=1 ;; *) break ;; esac shift done if [ $# = 0 ] then echo "$cmd: missing command" >&2 badopts=1 fi [ $badopts ] && { echo "$usage" >&2; exit 2; } tmpf=$TMPDIR/withstdin$$$ext trap '[ $keep ] || rm -f "$tmpf"' 0 trap '[ $keep ] || rm -f "$tmpf"; exit 1' 1 2 13 15 cat >"$tmpf" || exit 1 if [ -n "$cleanafter" ] then ( ( sleep "$cleanafter" rm -f "$tmpf" ) & ) fi # no exec because the trap must run "$@" "$tmpf"