2

I am using the mktemp to create a temp file in Makefile and using this MakeFile on RHEL5 U3 build environment.

setuptmp1=`mktemp setup.tmp.1.XXXXXXXX --tmpdir=/tmp` ; \

setuptmp2=`mktemp setup.tmp.2.XXXXXXXX --tmpdir=/tmp` ; \

Observed following message in build log.

mktemp: invalid option -- -

Usage: mktemp -V | -dqtu -p prefix template

What does this mean? Is something wrong in usage of mktemp ?

Joe
  • 63
  • 1
  • 6
  • have you tried the `$()` method? It's safer, and may handle this better. `setuptmp1="$(mktemp setup.tmp.1.XXXXXX --tmpdir=/tmp)"` – SnakeDoc Jun 28 '16 at 18:54
  • 2
    `mktemp` in rhel5 [is different](https://bugzilla.redhat.com/show_bug.cgi?id=1155729) then in rhel6. Check the man page for correct usage. – mata Jun 28 '16 at 18:55

2 Answers2

1

The mktemp utility has different sets of flags on different systems, depending on the version that ships with that system. The mktemp on OS X is also missing the --tmpdir option.

However, all versions of mktemp that I can see on my systems honors the TMPDIR environment variable when using -t (see the mktemp manual). So the following should work for you:

export TMPDIR="/tmp"
setuptmp1=$( mktemp -t setup.tmp.1.XXXXXXXX )
setuptmp2=$( mktemp -t setup.tmp.2.XXXXXXXX )
Kusalananda
  • 14,885
  • 3
  • 41
  • 52
0

According to check-kernel-headers: mktemp --tmpdir not available on RedHat RHEL5 ,

mktemp --tmpdir is not available on older Redhat RHEL5 machines. The alternative that has the same behavior is 'mktemp -t'.

There is a related bug-report (no backward compatibility either): RHEL6 mktemp uses -t to refer to what RHEL5 supported with -r: Bug 1155729RHEL5 and RHEL6: mktemp -t XXXXXX.pdf: functionality differs

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105