|
|
sybperl-l Archive
Up Prev Next
From: John_Erjavec at cargill dot com
Subject: Re: Using sybperl to automate 11.9.2 upgrade
Date: Feb 16 1999 6:07PM
This is one of the parts where I was having the problems:
=====================START OF CODE===========================
my $upgrd_message = qq[
I'm about to upgrade the server with the resource file. This will
take a while, but you can't log into the dataserver to check on it
until the upgrade is finished, or it will fail. Don't worry. I'll
let you know when I'm done.];
send_to_both($upgrd_message);
my $upgrade_prog = "$ENV{'SYBASE'}/bin/sqlupgraderes -r$res_file";
my $upgrade_success = 0;
open(UPGRD, "$upgrade_prog 2>&1 <&- |") or die "Could not run
'$upgrade_prog': $!";
select UPGRD; $| = 1;
while () {
$upgrade_success = 1 if /successfully/;
send_to_both($_);
}
close(UPGRD) or die "Could not close '$upgrade_prog': $!";
select STDOUT;
# my $upgrade_return = qx [ $upgrade_prog 2>&1 ];
# send_to_both( $upgrade_return );
#
# $upgrade_success = 1 if $upgrade_return =~ /successfully/;
#
if ( $upgrade_success ) {
send_to_both("SQL Server upgraded successfully.");
} else {
print STDERR "**** SQL Server upgrade failed. ****\n";
die "**** SQL Server upgrade failed. ****\n";
}
send_to_both("Done with sqlupgraderes.");
=====================END OF CODE===========================
send_to_both() is a function that sends a string to a log file and to STDERR.
When I put the '<&-' (to close STDIN) in the open() call, it seems to work. I
say 'seems' because it does get out of the script, but there were problems with
a database, so I am not sure. The commented out section hung, and it also hung
before I added the closing of STDIN to the open() call. I never actually tried
system() since I would like to read in the STDOUT and STDERR to the program, and
print it out so that people can verify that things are going well. I will need
to do this for the backupserver creation as well, and when I bounce the server,
I need to close everything, like so:
=====================START OF CODE===========================
# Shut down dataserver
$d->ct_sql("shutdown", \&scb);
$d = undef;
sleep 15; # Give it time to die
# Start Server
$run_msg = qx [ /sybdumps/sybase11/install/RUN_DS_CENTRAL >&- 2>&- <&- &
];
send_to_both($run_msg);
sleep 15; # Give it time to come back
$d = new Sybase::CTlib $login, $passwd, $server, $prog_label;
# Do more configuration
=====================END OF CODE===========================
Is there a better way to do this, or am I on the right track? Thanks for the
help.
-JEV
John Erjavec V
Cargill, Inc.
john_erjavec@cargill.com
______________________________ Reply Separator _________________________________
Subject: Re: Using sybperl to automate 11.9.2 upgrade
Author: mpeppler (mpeppler@mbay.net) at mtka-unix-mime
Date: 2/16/99 11:32 AM
>>>>> "John" == John Erjavec writes:
John> All- Has anyone had any experience using sybperl / perl to
John> automate the upgrade process? I seem to be running into some
John> problems, using HP-UX 10.20, perl 5.005_02, and sybperl 2.09.
John> The problems seem to stem from the fact that when I run
John> sqlupgraderes, it shuts down the dataserver, and spawns a new
John> one. I have tried using open(), qx[], and ``, but all hang
John> after the sqlupgrade process is finished. There is a
John> process that is the child of my upgrade script, and the parent
John> (my upgrade script) does not want to continue. Anybody run into
John> this? Anyone have any suggestions on how to get around it? Any
John> comments at all? I've been trying things for a week, and still
John> no luck. I need to get this figured out soon, so that I don't
John> let my part of the schedule slide. Thanks for any help anyone
John> can give.
Care to show us the upgrade script? Or at least the relevant portion?
One suggestion would be to use system() to execute the sqlupgrade
process, and check the return code (as far as I can see this should
really work...) Or do you call open() to read the output of the
sqlupgrade process in the parent script? Maybe you need to call wait
to reap all the children that got spawned, and make sure that you're
not blocking on some input/output (possibly your in a parent/child
deadlock of some sort).
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@mbay.net -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
|