[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl-win32-users
Subject:    RE Help
From:       "Carrel, Ian" <Ian.Carrel () getronics ! com>
Date:       2000-03-16 13:15:47
[Download RAW message or body]

I've written the following to change a path statement in a number of Batch
files. It does change the first instance of the path %path% statement but
not any of the following instances. Any ideas folks?

Perl Script
--------------------------

print "PLEASE TYPE THE SOURCE INSTALLATION DRIVE: ";
my $source = <STDIN>;
chomp ($source);
print "The source installation drive = $source\n";		

$filename = "$source\\directory\\directory\\file.bat";

$old = "$filename";
$new = "$filename.tmp.$$";
$bak = "$filename.bak";

open(OLD, "<$old")			or die "can't open $old: $!";
open(NEW, ">$new")			or die "can't open $new: $!";

while (<OLD>) {
	s/%path%/$source/;
		(print NEW $_)		or die "can't write to $new: $!";
}

close(OLD)				or die "can't close $old: $!";
close(NEW)				or die "can't close $new: $!";

rename($old, $bak);
rename($new, $old);

----------------------------------


File.bat
----------------------------------

echo installing Olivetti PR50 Printer...............

start /wait %path%Directory\Directory\winautom8.exe -debug
%path%Directory\Directory\Olipr2install.aut

-----------------------------------


tia

Ian Carrel MCSE
Software Designer
Networking & Communications
Business Solutions
Getronics

mailto: ian.carrel@getronics.com <mailto: ian.carrel@getronics.com> 

T.  +44 (0) 1132 734771
M. +44 (0) 7977 222 434
F.  +44 (0) 1132 735223

http://www.getronics.com/ <http://www.getronics.com/> 
'building futures'


---
You are currently subscribed to perl-win32-users as: [perl-win32-users@progressive-comp.com]
To unsubscribe, forward this message to
         leave-perl-win32-users-90392J@lyris.ActiveState.com
For non-automated Mailing List support, send email to  
         ListHelp@ActiveState.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic