help with perl syntax

T

tedqn

Program: Aspell

I need to change the tempfile physical directory to the current
location of the page, ie.
/scriptfiles/speller/tmpfile where I can grant write permission to the
anonymous web account. I'm migrating the site to win 2003 server with
much stricter security. The program currently trying to create a temp
file in the windows temp directory
C:\WINDOWS\TEMP\KLkU8sBUpb\gZ0BZIy9BL which is the system direcotry and
was denied.

use File::Temp qw/ tempfile tempdir /;

....

my $dir = tempdir( CLEANUP => 1 );
my( $fh, $tmpfilename ) = tempfile( DIR => $dir );

# temp file was created properly?

# open temp file, add the submitted text.
for( my $i = 0; $i <= $#textinputs; $i++ ) {
$text = url_decode( $textinputs[$i] );
@lines = split( /\n/, $text );
print $fh "\%\n"; # exit terse mode
print $fh "^$input_separator\n";
print $fh "!\n"; # enter terse mode
for my $line ( @lines ) {
# use carat on each line to escape possible aspell commands
print $fh "^$line\n";
}

}
# exec aspell command
my $cmd = "$aspell_cmd $aspell_opts < $tmpfilename 2>&1";
open ASPELL, "$cmd |" or handleError( "Could not execute `$cmd`\\n$!" )
and return;

..........
Could not execute `"C:/Program Files/Aspell/bin/aspell" -a --lang=en_US
--encoding=utf-8 --add-extra-dicts=en_MED.rws <
C:\WINDOWS\TEMP\KLkU8sBUpb\gZ0BZIy9BL 2>&1`\nBad file descriptor
 
U

usenet

I need to change the tempfile physical directory to the current
location of the page, ie.
/scriptfiles/speller/tmpfile where I can grant write permission to the
anonymous web account.
...
use File::Temp qw/ tempfile tempdir /;
...
my $dir = tempdir( CLEANUP => 1 );
my( $fh, $tmpfilename ) = tempfile( DIR => $dir );

Are you saying that File::Temp is creating temp directories and files
in the wrong place? You can force File::Temp to work within a
particular root directory:

$tempdir = tempdir ( DIR => '/scriptfiles/speller/tmpfile' );

If that's not what you're asking, then you need to ask it more clearly.
The posting guidlines for this group can help you do that:
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
T

tedqn

re you saying that File::Temp is creating temp directories and files in
the wrong place?
- Yes, the application uses the environment variable. All I want to do
is to change the directory to
/scriptfiles/speller/tmpfile
- I tried your line of code and it return a cgi error. Isn't it
supposed to be above

my $dir = tempdir( CLEANUP => 1 );

so that the previous temp file got cleaned up?

I'm an ASP programmer so I'm pretty much lost with Perl.
 
U

usenet

- I tried your line of code and it return a cgi error.

That statement doesn't help me help you. WHAT error?

You should be carping your error messages by adding this near the top
of your script:

use CGI::Carp qw{ fatalsToBrowser carpout };

Tell me what it carps.
 
T

tedqn

Thanks for all the help. As usual, the problem was discovered to be
completely something else...

On Windows 2003 and IIS 6, the IUSR_MACHINENAME account needs to have
execute permission granted to c:\windows\system32\cmd.exe in order to
execute the aspell command.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top