This is the mail archive of the
cygwin
mailing list for the Cygwin project.
reading /proc/registry/ causes Segmentation fault.
- From: "DEWI - N. Zacharias" <N dot Zacharias at dewi dot de>
- To: "cygwin at cygwin dot com" <cygwin at cygwin dot com>
- Date: Wed, 5 May 2010 10:57:31 +0200
- Subject: reading /proc/registry/ causes Segmentation fault.
Hi all,
The script below worked without problems last month. But now I get Segmentation fault (core dumped).
If I use the lines which begins with
#this works fine
instead of the one with GetWordExe it works fine.
I tested it with the latest update
Sorry that it is not shorter but it is the shortes form to get it work.
Have a nice day
Norbert
###################################################################################
#! /usr/bin/perl -w
use IO::File;
my $RegistryOffice = '/proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Office/';
my ($Reg_Word_Exe,$Reg_Office_Ver,$Reg_Word_Path);
sub GetOfficeVer
{
if($Reg_Office_Ver)
{
return($Reg_Office_Ver);
}
opendir( my $ww, $RegistryOffice);
my @a = grep{m/\d+\.\d+/}readdir($ww);
closedir($ww);
foreach my $tr(@a)
{
my $w = $RegistryOffice.$tr.'/Word/InstallRoot/Path';
if( -f $w)
{
$Reg_Office_Ver = $tr;
my $ww = IO::File->new("< $w");
$Reg_Word_Path = <$ww>;
$ww->close();
$Reg_Word_Path =~ s/\r*\n//;
$Reg_Word_Path =~ s/\x0//;
last;
}
}
return($Reg_Office_Ver);
}
sub GetWordExe
{
if($Reg_Word_Exe)
{
return($Reg_Word_Exe);
}
if(!$Reg_Office_Ver)
{
GetOfficeVer();
}
opendir(my $ww,$Reg_Word_Path);
my @wa = grep{ m/^.*word\.exe/i} readdir($ww);
closedir($ww);
if(!@wa)
{
return(undef);
}
$Reg_Word_Exe = $Reg_Word_Path.$wa[0];
return( $Reg_Word_Exe);
}
############################### here the script start working############
my $myDir = "/cygdrive/g/somedir";
my $myDoc = ' aname.doc /mamacro';
my $WordExe = Cygwin::win_to_posix_path(GetWordExe(),1);
#this works fine my $xx = 'C:\Programme\Microsoft Office\Office12\WINWORD.EXE';
#this works fine my $WordExe = Cygwin::win_to_posix_path($xx,1);
$WordExe =~s/ /\\ /g;
$WordExe.=$myDoc ;
system('cd '.$somedir.";\n".$WordExe);
sleep(3);
while(1)
{
print "*";
my $ls = IO::File->new("ps -Wa |");
my @l = grep{ s/\n// && m/WINWORD\.EXE/ }<$ls>;
if(! @l)
{
last;
}
$ls->close();
}
exit;
##################################################
--------------------------------------------------------------------------
Dipl. Phys.
Norbert Zacharias
Wind Measurements & Power Curve Measurements
DEWI GmbH
Ebertstrasse 96
26382 Wilhelmshaven
Germany
Tel.: +49 4421 4808 876
Fax: +49 4421 4808 843
Email: N.Zacharias@dewi.de
Home: http://http://www.dewi.de
DEWI GmbH - Deutsches Windenergie-Institut, Wilhelmshaven
Commercial Register No.: Amtsgericht Oldenburg, HRB 130241
Managing Director: Jens Peter Molly
Chairman of the supervisory board: Ministerialrat Dr. Niels Kämpny
P Please consider the environment before printing this email.
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple