Joe
Joe

Reputation: 63

mktemp: invalid option -- - on RHEL5 U3

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 ?

Upvotes: 2

Views: 817

Answers (2)

Kusalananda
Kusalananda

Reputation: 15633

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 )

Upvotes: 1

Thomas Dickey
Thomas Dickey

Reputation: 54603

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

Upvotes: 0

Related Questions