Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere does CGI.pm normally create temporary files?
    primarykey
    data
    text
    <p>On all my Windows servers, except for one machine, when I execute the following code to allocate a temporary files folder:</p> <pre><code>use CGI; my $tmpfile = new CGITempFile(1); print "tmpfile='", $tmpfile-&gt;as_string(), "'\n"; </code></pre> <p>The variable <code>$tmpfile</code> is assigned the value <code>'.\CGItemp1'</code> and this is what I want. But on one of my servers it's incorrectly set to <code>C:\temp\CGItemp1</code>.</p> <p>All the servers are running Windows 2003 Standard Edition, IIS6 and ActivePerl 5.8.8.822 (upgrading to later version of Perl not an option). The result is always the same when running a script from the command line or in IIS as a CGI script (where scriptmap <code>.pl</code> = <code>c:\perl\bin\perl.exe "%s" %s</code>).</p> <p>How I can fix this Perl installation and force it to return '<code>.\CGItemp1</code>' by default?</p> <p>I've even copied the whole Perl folder from one of the working servers to this machine but no joy.</p> <p><a href="https://stackoverflow.com/questions/86175/where-is-cgi-pm-supposed-to-create-temporary-files/86200#86200">@Hometoast:</a></p> <p>I checked the '<code>TMP</code>' and '<code>TEMP</code>' environment variables and also <code>$ENV{TMP}</code> and <code>$ENV{TEMP}</code> and they're identical. </p> <p>From command line they point to the user profile directory, for example: </p> <blockquote> <p><code>C:\DOCUME~1\[USERNAME]\LOCALS~1\Temp\1</code></p> </blockquote> <p>When run under IIS as a CGI script they both point to:</p> <blockquote> <p><code>c:\windows\temp</code></p> </blockquote> <p>In registry key <code>HKEY_USERS/.DEFAULT/Environment</code>, both servers have:</p> <blockquote> <p><code>%USERPROFILE%\Local Settings\Temp</code></p> </blockquote> <p>The ActiveState implementation of <code>CGITempFile()</code> is clearly using an alternative mechanism to determine how it should generate the temporary folder.</p> <p><a href="https://stackoverflow.com/questions/86175/where-is-cgi-pm-supposed-to-create-temporary-files/86993#86993">@Ranguard:</a></p> <p>The real problem is with the <code>CGI.pm</code> module and attachment handling. Whenever a file is uploaded to the site <code>CGI.pm</code> needs to store it somewhere temporary. To do this <code>CGITempFile()</code> is called within <code>CGI.pm</code> to allocate a temporary folder. So unfortunately I can't use <code>File::Temp</code>. Thanks anyway.</p> <p><a href="https://stackoverflow.com/questions/86175/where-is-cgi-pm-supposed-to-create-temporary-files/86874#86874">@Chris:</a></p> <p>That helped a bunch. I did have a quick scan through the <code>CGI.pm</code> source earlier but your suggestion made me go back and look at it more studiously to understand the underlying algorithm. I got things working, but the oddest thing is that there was originally no <code>c:\temp</code> folder on the server. </p> <p>To obtain a temporary fix I created a <code>c:\temp</code> folder and set the relevant permissions for the website's anonymous user account. But because this is a shared box I couldn't leave things that way, even though the temp files were being deleted. To cut a long story short, I renamed the <code>c:\temp</code> folder to something different and magically the correct '<code>.\</code>' folder path was being returned. I also noticed that the customer had enabled FrontPage extensions on the site, which removes write access for the anonymous user account on the website folders, so this permission needed re-applying. I'm still at a loss as to why at the start of this issue <code>CGITempFile()</code> was returning <code>c:\temp</code>, even though that folder didn't exist, and why it magically started working again.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload