in reply to Re: invoke tempdir() failed
in thread invoke tempdir() failed

The web server account is the same as the one who creates temporary directory in Solaris command line directly. It is weird that the same programme works by running 'perl test.pl',however, when the same code section is invoked in a web-based procedure, I can't find the temporary directory by 'ls -l /tmp/temp_dir_created_by_File_Temp'.
#!/usr/bin/perl use strict; use warnings; use File::Temp qw/ tempfile tempdir /; my $temp_dir = tempdir(); $temp_dir =~ /\/tmp\/(.*)/; my $temp_dir_name = $1; my $grep_str = "ls -l /tmp | grep $1"; my $res2 = `$grep_str`; print "[$grep_str]grep result [$res2]\n";

Replies are listed 'Best First'.
Re^3: invoke tempdir() failed
by Anonymous Monk on Oct 08, 2011 at 13:13 UTC
    ugh, try this
    #!/usr/bin/perl -- use strict; use warnings; use Cwd; use File::Temp qw/ tempfile tempdir /; print cwd(), "\n"; my $temp_dir = tempdir(); chdir $temp_dir or die "Cannot chdir to '$temp_dir': $!"; print cwd(), "\n"; __END__
      thanks for the advice !