1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
--- local/fixproc.orig 2005-05-18 09:57:16.000000000 -0400
+++ local/fixproc 2005-05-18 11:00:38.000000000 -0400
@@ -129,6 +129,9 @@
#
# Timothy Kong 3/1995
+require File::Temp;
+use File::Temp();
+
$database_file = '/local/etc/fixproc.conf';
$debug = 0; # specify debug level using -dN
@@ -196,7 +199,6 @@
printf (stderr "create_sh_script\n") if ($debug > 0);
$! = $fixproc_error;
- open (file, ">"."$file") || die "$0: cannot open $file\n";
while ( $shell_lines[$i] ne $shell_end_marker )
{
printf (file "%s", $shell_lines[$i]);
@@ -231,13 +233,13 @@
{
# it must be "shell", so execute the shell script defined in database
- local ($tmpfile) = "/tmp/fix_$$";
+ local ($tmpfile) = new File::Temp(TEMPLATE => 'fix_XXXXX',
+ DIR => '/tmp');
&create_sh_script ($fix{$proc}, $tmpfile);
# return code is number divided by 256
$error_code = (system "$tmpfile") / 256;
- system "rm $tmpfile";
return ($fix_failed_error) if ($error_code != 0);
# sleep needed here?
return &do_exist ($proc);
@@ -262,13 +264,13 @@
# if not "exist", then it must be "shell", so execute the shell script
# defined in database
- local ($tmpfile) = "/tmp/check_$$";
+ local ($tmpfile) = new File::Temp(TEMPLATE => 'check_XXXXXX',
+ DIR => '/tmp');
&create_sh_script ($check{$proc}, $tmpfile);
# return code is number divided by 256
$error_code = (system "$tmpfile") / 256;
- system "rm $tmpfile";
return ($check_failed_error) if ($error_code != 0);
# check passed, continue
|