~ubuntu-branches/ubuntu/maverick/slony1/maverick

« back to all changes in this revision

Viewing changes to tools/altperl/slonik_execute_script.pl

  • Committer: Bazaar Package Importer
  • Author(s): Peter Eisentraut
  • Date: 2006-11-17 17:19:48 UTC
  • mfrom: (1.1.2 upstream) (2.1.1 etch)
  • Revision ID: james.westby@ubuntu.com-20061117171948-jd89seng1dcff6rc
Tags: 1.2.1-1
* New upstream release
  - Updated no-client-log.patch
  - Obsoleted patches: hardcoded-paths.patch
* Updated watch file
* Reenabled Perl tools
* Added missing final newline to slon.conf-sample
* Updated test script

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!@@PERL@@
2
 
# $Id: slonik_execute_script.pl,v 1.1 2005/05/31 16:11:05 cbbrowne Exp $
 
2
# $Id: slonik_execute_script.pl,v 1.1.4.1 2006/10/27 17:54:21 cbbrowne Exp $
3
3
# Author: Christopher Browne
4
4
# Copyright 2004 Afilias Canada
5
5
 
6
6
use Getopt::Long;
 
7
use File::Temp qw(tempfile);
7
8
 
8
9
# Defaults
9
10
$CONFIG_FILE = '@@SYSCONFDIR@@/slon_tools.conf';
14
15
# the get_set function.
15
16
$node = 0;
16
17
 
 
18
# temp file variable for script handling
 
19
my $filename = '';
 
20
my $fh       = undef;
 
21
 
17
22
# Read command-line options
18
23
GetOptions("config=s" => \$CONFIG_FILE,
19
24
           "help"     => \$SHOW_USAGE,
69
74
}
70
75
elsif ($SCRIPT_ARG) {
71
76
    # Put the script into a file
72
 
    $file = "/tmp/execute_script.sql.$$";
73
 
    my $fh;
74
 
    open $fh, ">", $file;
 
77
    ($fh, $filename) = tempfile();
75
78
    print $fh $SCRIPT_ARG;
76
79
    close $fh;
77
80
}
80
83
    die $USAGE;
81
84
}
82
85
 
83
 
my $FILE="/tmp/gensql.$$";
84
 
open(SLONIK, ">", $FILE);
85
 
print SLONIK genheader();
86
 
print SLONIK "  execute script (\n";
87
 
print SLONIK "    set id = $set,\n";
88
 
print SLONIK "    filename = '$file',\n";
89
 
print SLONIK "    event node = $node\n";
90
 
print SLONIK "  );\n";
91
 
close SLONIK;
92
 
run_slonik_script($FILE);
 
86
my $slonik = '';
 
87
 
 
88
$slonik .= genheader();
 
89
$slonik .= "  execute script (\n";
 
90
$slonik .= "    set id = $set,\n";
 
91
$slonik .= "    filename = '$filename',\n";
 
92
$slonik .= "    event node = $node\n";
 
93
$slonik .= "  );\n";
 
94
 
 
95
run_slonik_script($slonik, 'EXECUTE SCRIPT');