[28798] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 42 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 17 11:05:43 2007

Date: Wed, 17 Jan 2007 08:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 17 Jan 2007     Volume: 11 Number: 42

Today's topics:
    Re: how to use clearcase commands in perl script <tadmc@augustmail.com>
    Re: Map Windows from Unix <veatchla@yahoo.com>
    Re: Module for user preferences ~/. file (NOSPAM)
        parse body mime message jcharth@hotmail.com
    Re: Perl DBI PostgreSQL <ch.l.ngre@online.de>
    Re: Runs Fine In Perl :: Not As Cron Job anno4000@radom.zrz.tu-berlin.de
    Re: Variable substitution <wahab-mail@gmx.de>
    Re: Variable substitution <sebastien.godier@gmail.com>
    Re: Variable substitution anno4000@radom.zrz.tu-berlin.de
    Re: Variable substitution <sebastien.godier@gmail.com>
    Re: Variable substitution anno4000@radom.zrz.tu-berlin.de
    Re: Variable substitution <sebastien.godier@gmail.com>
    Re: Variable substitution <sebastien.godier@gmail.com>
    Re: Variable substitution <sebastien.godier@gmail.com>
    Re: Variable substitution (NOSPAM)
    Re: Variable substitution <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 17 Jan 2007 10:01:15 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: how to use clearcase commands in perl script
Message-Id: <slrneqsi2b.g96.tadmc@tadmc30.august.net>

sunil <sunil.vvn@gmail.com> wrote:

>          Presently I am having a requirement to use clearcase commands
> in a perl script.


   http://search.cpan.org/search?query=ClearCase


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 17 Jan 2007 09:09:02 -0600
From: l v <veatchla@yahoo.com>
Subject: Re: Map Windows from Unix
Message-Id: <12qsf0ff6lae2a3@news.supernews.com>

Andrew DeFaria wrote:

--------------030002080909070001070104
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
   <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
   <title></title>
</head>

<body bgcolor="#ffffff" text="#000000">
Martijn Lievaart wrote:
<blockquote
  cite="midpan.2007.01.17.08.03.23.939491@remove.this.part.rtij.nl"
  type="cite">On Tue, 16 Jan 2007 19:27:27 -0600, Andrew DeFaria wrote:<br>
   <blockquote type="cite">It's pretty funny that you don't recognize
that that's pretty much the same thing!<br>
   </blockquote>
<!---->Well, there is a slight difference. Samba exports smb mounts, a
cifs capable kernel imports smb mounts. Small difference. Big impact.<br>
   <br>
Please try to follow your own advice, install samba on a non cifs
capable kernel and try to mount a remote share from a Windows PC. Now
try the same without samba on a cifs capable kernel. The first won't
work, the second<br>
will.<br>
</blockquote>
I'm not sure what you mean by a "cifs" capable kernel. I've used Samba
to mount a remote share from a Windows PC and it worked just fine.<br>
<blockquote
  cite="midpan.2007.01.17.08.03.23.939491@remove.this.part.rtij.nl"
  type="cite">
   <blockquote type="cite">Damn it's great to know that these ASCII only
experts are so well informed!<br>
   </blockquote>

<!---->Please think before you post, especially when you are utterly
wrong.<br>
</blockquote>
Heed your own advice!<br>
<blockquote
  cite="midpan.2007.01.17.08.03.23.939491@remove.this.part.rtij.nl"
  type="cite">
   <blockquote type="cite">If you want to bone up on the subject:
<a class="moz-txt-link-freetext" 
href="http://en.wikipedia.org/wiki/Server_message_block">http://en.wikipedia.org/wiki/Server_message_block</a><br>
   </blockquote>
<!---->I probably know more about CIFS/SMB in my pinky then you will in
your lifetime, thank you. Not that I want to, but I have to debug the
stuff.<br>
</blockquote>
Damn all that experience and still he's confused.<br>
<blockquote
  cite="midpan.2007.01.17.08.03.23.939491@remove.this.part.rtij.nl"
  type="cite">Oh, and please don't post in HTML and put some whitespace
in your posts.<br>
</blockquote>
Ah... respectfully.... no.<br>

<blockquote
  cite="midpan.2007.01.17.08.03.23.939491@remove.this.part.rtij.nl"
  type="cite">As you may notice, you are the *only* one posting html
here.</blockquote>
I could give a flying fuck if I am the only one here.<br>

Andrew - I feel the same about *you*.  BTW, I *love* reading html code.

<blockquote
  cite="midpan.2007.01.17.08.03.23.939491@remove.this.part.rtij.nl"
  type="cite"> It's anti social. It's hard to read.<br>
</blockquote>
You shouldn't really talk about being anti social - you reek of it!<br>
<blockquote
  cite="midpan.2007.01.17.08.03.23.939491@remove.this.part.rtij.nl"
  type="cite">M4<br>
</blockquote>
I mean hell you don't even have a real name! <span
  class="moz-smiley-s1"><span> :-) </span></span><br>
<div class="moz-signature">-- <br>

<a href="http://defaria.com">Andrew DeFaria</a><br>
<small><font color="#999999">Why is it that anybody going slower than
you is an idiot, and anyone going faster is a maniac.</font></small>
</div>
</body>
</html>

--------------030002080909070001070104--


-- 

Len


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

Date: Wed, 17 Jan 2007 09:05:25 -0600
From: "Mumia W. (NOSPAM)" <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Module for user preferences ~/. file
Message-Id: <eolg55$hu3$1@aioe.org>

On 01/17/2007 05:14 AM, traggatt@gmail.com wrote:
> Hi
> 
> Does anyone know a module which will store/retreive user preferences
> into a ~/.scriptprefs type file (e.g. like ~/.bashrc)?
> 
> Cheers
> Tim
> 

Config::IniFiles


-- 
Windows Vista and your freedom in conflict:
http://techdirt.com/articles/20061019/102225.shtml


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

Date: 17 Jan 2007 07:40:41 -0800
From: jcharth@hotmail.com
Subject: parse body mime message
Message-Id: <1169048440.672219.109590@51g2000cwl.googlegroups.com>

Hello I am downloading a mime from a web server using lwp
my $fullpage = $ua->request($req)->as_string;
then i was trying to extract the text body of the mesage using MIME
tools but i cant seem get this to work
when i do
$parser->parse_data($fullpage)
i get
Can't use string ("MIME::Parser") as a HASH ref while "strict refs" in
use at /usr/lib/perl5/site_perl/5.8.0/MIME/Parser.pm line 279.

not sure what i am doing wrong
thanks.



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

Date: Wed, 17 Jan 2007 15:06:16 +0100
From: Ch Lamprecht <ch.l.ngre@online.de>
Subject: Re: Perl DBI PostgreSQL
Message-Id: <eolagm$317$1@online.de>

raminoacid schrieb:
> Hi,
> 
> I'm using Perl's DBI package to connect to a PostgreSQL database.
> Everything works fine except the annoying  DEBUG: output for each DB
> operation. This is not the same as tracing since the later can be
> disabled. For instance, the following output can be seen in my
> terminal:
> 
> DEBUG:  InitPostgres
> DEBUG:  StartTransaction
> DEBUG:  name: unnamed; blockState:       DEFAULT; state: INPROGR,
> xid/subid/cid: 2082592/1/0, nestlvl: 1, children: <>
> DEBUG:  CommitTransaction
> DEBUG:  name: unnamed; blockState:       STARTED; state: INPROGR,
> xid/subid/cid: 2082592/1/0, nestlvl: 1, children: <>
> 
> 
> Is there anyway to disable this. I need to parse my output file and I'd
> like to have a light-weight file rather a file with lots of garbage.
> 
> Thanks.
> 

Change your setting for the parameter 'client_min_messages' in postgresql.conf 
to 'notice' or comment it out.

HTH, Christoph



-- 

perl -e "print scalar reverse q/ed.enilno@ergn.l.hc/"


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

Date: 17 Jan 2007 15:19:56 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Runs Fine In Perl :: Not As Cron Job
Message-Id: <516t4sF1iu1pkU1@mid.dfncis.de>

John W. Kennedy <jwkenne@attglobal.net> wrote in comp.lang.perl.misc:
> Paul Lalli wrote:
> > Tad McClellan wrote:
> >> Paul Lalli <mritty@gmail.com> wrote:
> >>> Bucker wrote:
> >>>> system("cd /home/website/www/htdocs/batch/");
> >>> This is a no-op.  It does absolutley nothing worth mentioning.
> >> So the OP should use Perl's builtin operator for changing
> >> the current working directory:
> >>
> >>    perldoc -f chdir
> > 
> > Well, in the general case, yes.  But in the OP's specific example,
> > there was no reason to change directory at all, as he specified the
> > full path to the file to unzip in the second system() call.
> 
> But not the path to output to.

In fact I think Perl is more of a hindrance than a help with this
little cron job.  We don't know the full story, but a series of shell
commands ought to do the job:

    cd /x/y/z; unzip /hihi/haha/huhu.zip; echo "unzip cron job done"

Note that cron mails the output (of echo) to the user, so that takes
care of the email.

If this fails, the error message will also be mailed.  Perl has hidden
the error.

Anno


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

Date: Wed, 17 Jan 2007 15:06:10 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Variable substitution
Message-Id: <eolaq6$g6i$1@mlucom4.urz.uni-halle.de>

sebastien.godier@gmail.com wrote:
> So, I'm trying to generate my external command using this variable
> inside a loop. Like this
> 
> system ("REG QUERY \"\\\\$_\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
> Explorer\\Main\" /v \"Start Page");
> 
> The problem is that $_ is not substituted at all. If I replace $_ by a
> real computer name, it works. But I don't know how to declare $_ as a
> variable in this line.

Show your loop!

Regards

M.


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

Date: 17 Jan 2007 06:19:37 -0800
From: "Seb" <sebastien.godier@gmail.com>
Subject: Re: Variable substitution
Message-Id: <1169043577.147895.277320@38g2000cwa.googlegroups.com>

Ok so here my complete script:


##############
#!C:\Perl\bin\perl.exe -w
#

# Read the list of computer to run the script against
open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
exist.");

# When a computer is unavailable, write it name to the log file.
open(OUTPUTFILE,">errors.txt");

# For debugging purpose
open(DEBUGPING,">debug-ping.txt");
open(DEBUGCOMMANDS,">debug-commands.txt");

system("cls");
while (<INPUTFILE>) {
	$debugping = `ping -n 1 $_ 2>&1`;
	if ( $? >> 8 == 1 )
		{
		# That means the computers is unreachable. Exporting the name of such
computers to the log file.
		print OUTPUTFILE "$_";
		# chomp remove the \n from $_ variable to print it correctly to
STDOUT
		chomp($_);
		print  "\n\t\t\t $_ FAILED.";
		}
	else
		{
		# The computer is on the network. Let's run the commands against it.
		open(DEBUGCOMMANDS,">>debug-commands.txt");
		print DEBUGCOMMANDS "$_\n";
		system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
Explorer\\Main\" /v \"Start Page");

		# chomp remove the \n from $_ variable to print it correctly to
STDOUT
		chomp($_);
		print "\n$_ successfull.";
		}
print DEBUGPING $debugping;

#############



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

Date: 17 Jan 2007 14:25:58 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Variable substitution
Message-Id: <516pvmF1ir74uU1@mid.dfncis.de>

Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> Ok so here my complete script:

[snipped except]

> 		system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Internet

The variable $cpname you try to interpolate is nowhere defined.  If
you had switched on warnings, Perl would have told you so.

Change $cpname to $_ and it will work.  And, please, before you
ask hundreds of people for help, take *one* close look at your code.

Anno


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

Date: 17 Jan 2007 06:32:32 -0800
From: "Seb" <sebastien.godier@gmail.com>
Subject: Re: Variable substitution
Message-Id: <1169044352.097746.132490@51g2000cwl.googlegroups.com>

anno4...@radom.zrz.tu-berlin.de a =E9crit :
> Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> > Ok so here my complete script:
>
> [snipped except]
>
> > 		system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
>
> The variable $cpname you try to interpolate is nowhere defined.  If
> you had switched on warnings, Perl would have told you so.
>
> Change $cpname to $_ and it will work.  And, please, before you
> ask hundreds of people for help, take *one* close look at your code.
>
> Anno

Will searching the solution, I realized that I posted a wrong version
of my script. I deleted it and now here is the good one.

###############
#!C:\Perl\bin\perl.exe
#

# Read the list of computer to run the script against
open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
exist.");

# When a computer is unavailable, write it name to the log file.
open(OUTPUTFILE,">errors.txt");

# For debugging purpose
open(DEBUGPING,">debug-ping.txt");
open(DEBUGCOMMANDS,">debug-commands.txt");

system("cls");
while (<INPUTFILE>) {
	$debugping =3D `ping -n 1 $_ 2>&1`;
	if ( $? >> 8 =3D=3D 1 )
		{
		# That means the computers is unreachable. Exporting the name of such
computers to the log file.
		print OUTPUTFILE "$_";
		# chomp remove the \n from $_ variable to print it correctly to
STDOUT
		chomp($_);
		print  "\n\t\t\t $_ FAILED.";
		}
	else
		{
		# The computer is on the network. Let's run the commands against it.
		open(DEBUGCOMMANDS,">>debug-commands.txt");
		print DEBUGCOMMANDS "$_\n";
		system ("REG QUERY \"\\\\$_\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
Explorer\\Main\" /v \"Start Page");

		# chomp remove the \n from $_ variable to print it correctly to
STDOUT
		chomp($_);
		print "\n$_ successfull.";
		}
print DEBUGPING $debugping;
}

##########

So to answer you Anno, this typo was not the source of my problem. This
is the script causing me problem. $_ is not getting subsituted
correctly. But replacing $_ by a real computer name works fine.

Sebastien



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

Date: 17 Jan 2007 14:50:29 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Variable substitution
Message-Id: <516rdlF1ilh67U1@mid.dfncis.de>

Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> anno4...@radom.zrz.tu-berlin.de a écrit :
> > Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> > > Ok so here my complete script:
> >
> > [snipped except]
> >
> > > 		system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
> >
> > The variable $cpname you try to interpolate is nowhere defined.  If
> > you had switched on warnings, Perl would have told you so.
> >
> > Change $cpname to $_ and it will work.  And, please, before you
> > ask hundreds of people for help, take *one* close look at your code.
> >
> > Anno
> 
> Will searching the solution, I realized that I posted a wrong version
> of my script. I deleted it and now here is the good one.

Oh boy...  Please take some more care with your postings.

> ###############
> #!C:\Perl\bin\perl.exe
> #
> 
> # Read the list of computer to run the script against
> open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
> exist.");
> 
> # When a computer is unavailable, write it name to the log file.
> open(OUTPUTFILE,">errors.txt");
> 
> # For debugging purpose
> open(DEBUGPING,">debug-ping.txt");
> open(DEBUGCOMMANDS,">debug-commands.txt");
> 
> system("cls");
> while (<INPUTFILE>) {
> 	$debugping = `ping -n 1 $_ 2>&1`;
> 	if ( $? >> 8 == 1 )
> 		{
> 		# That means the computers is unreachable. Exporting the name of such
> computers to the log file.
> 		print OUTPUTFILE "$_";
> 		# chomp remove the \n from $_ variable to print it correctly to
> STDOUT
> 		chomp($_);
> 		print  "\n\t\t\t $_ FAILED.";
> 		}
> 	else
> 		{
> 		# The computer is on the network. Let's run the commands against it.
> 		open(DEBUGCOMMANDS,">>debug-commands.txt");
> 		print DEBUGCOMMANDS "$_\n";
> 		system ("REG QUERY \"\\\\$_\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
> Explorer\\Main\" /v \"Start Page");
> 
> 		# chomp remove the \n from $_ variable to print it correctly to
> STDOUT
> 		chomp($_);
> 		print "\n$_ successfull.";
> 		}
> print DEBUGPING $debugping;
> }
> 
> ##########
> 
> So to answer you Anno, this typo was not the source of my problem.

Too bad you wasted everybody's time with it.

> This
> is the script causing me problem. $_ is not getting subsituted
> correctly. But replacing $_ by a real computer name works fine.

How do you know $_ is not substituted?  Have you printed the string
instead of giving it to system(), so you can see what's actually in
there?

I have done so after making runnable code from your text.  I made $_
contain "xxxxxxxxx" and it printed

    REG QUERY "\\xxxxxxxxx\HKLM\SOFTWARE\MICROSOFT\Internet Explorer\Main"
    /v "Start Page

on a single line.  How is that not what you would expect?

Anno


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

Date: 17 Jan 2007 06:57:39 -0800
From: "Seb" <sebastien.godier@gmail.com>
Subject: Re: Variable substitution
Message-Id: <1169045859.409383.90050@q2g2000cwa.googlegroups.com>


anno4...@radom.zrz.tu-berlin.de a =E9crit :
> Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> > anno4...@radom.zrz.tu-berlin.de a =E9crit :
> > > Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> > > > Ok so here my complete script:
> > >
> > > [snipped except]
> > >
> > > > 		system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Inte=
rnet
> > >
> > > The variable $cpname you try to interpolate is nowhere defined.  If
> > > you had switched on warnings, Perl would have told you so.
> > >
> > > Change $cpname to $_ and it will work.  And, please, before you
> > > ask hundreds of people for help, take *one* close look at your code.
> > >
> > > Anno
> >
> > Will searching the solution, I realized that I posted a wrong version
> > of my script. I deleted it and now here is the good one.
>
> Oh boy...  Please take some more care with your postings.
>
> > ###############
> > #!C:\Perl\bin\perl.exe
> > #
> >
> > # Read the list of computer to run the script against
> > open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
> > exist.");
> >
> > # When a computer is unavailable, write it name to the log file.
> > open(OUTPUTFILE,">errors.txt");
> >
> > # For debugging purpose
> > open(DEBUGPING,">debug-ping.txt");
> > open(DEBUGCOMMANDS,">debug-commands.txt");
> >
> > system("cls");
> > while (<INPUTFILE>) {
> > 	$debugping =3D `ping -n 1 $_ 2>&1`;
> > 	if ( $? >> 8 =3D=3D 1 )
> > 		{
> > 		# That means the computers is unreachable. Exporting the name of such
> > computers to the log file.
> > 		print OUTPUTFILE "$_";
> > 		# chomp remove the \n from $_ variable to print it correctly to
> > STDOUT
> > 		chomp($_);
> > 		print  "\n\t\t\t $_ FAILED.";
> > 		}
> > 	else
> > 		{
> > 		# The computer is on the network. Let's run the commands against it.
> > 		open(DEBUGCOMMANDS,">>debug-commands.txt");
> > 		print DEBUGCOMMANDS "$_\n";
> > 		system ("REG QUERY \"\\\\$_\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
> > Explorer\\Main\" /v \"Start Page");
> >
> > 		# chomp remove the \n from $_ variable to print it correctly to
> > STDOUT
> > 		chomp($_);
> > 		print "\n$_ successfull.";
> > 		}
> > print DEBUGPING $debugping;
> > }
> >
> > ##########
> >
> > So to answer you Anno, this typo was not the source of my problem.
>
> Too bad you wasted everybody's time with it.
>
> > This
> > is the script causing me problem. $_ is not getting subsituted
> > correctly. But replacing $_ by a real computer name works fine.
>
> How do you know $_ is not substituted?  Have you printed the string
> instead of giving it to system(), so you can see what's actually in
> there?
>
> I have done so after making runnable code from your text.  I made $_
> contain "xxxxxxxxx" and it printed
>
>     REG QUERY "\\xxxxxxxxx\HKLM\SOFTWARE\MICROSOFT\Internet Explorer\Main"
>     /v "Start Page
>
> on a single line.  How is that not what you would expect?
>
> Anno


You put me on the way !! The problem comes from the new line character.
In other word, the REG QUERY line is splitted like this due to this
character:

REG QUERY "\\xxxxxxxxx
\HKLM\SOFTWARE\MICROSOFT\Internet Explorer\Main"

So, I must remove this character from $_. Trying with chomp($_) is not
making it. But I think I can succeed using a temporar variable.

Sebastien



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

Date: 17 Jan 2007 06:58:12 -0800
From: "Seb" <sebastien.godier@gmail.com>
Subject: Re: Variable substitution
Message-Id: <1169045892.288174.93290@q2g2000cwa.googlegroups.com>


anno4...@radom.zrz.tu-berlin.de a =E9crit :
> Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> > anno4...@radom.zrz.tu-berlin.de a =E9crit :
> > > Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> > > > Ok so here my complete script:
> > >
> > > [snipped except]
> > >
> > > > 		system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Inte=
rnet
> > >
> > > The variable $cpname you try to interpolate is nowhere defined.  If
> > > you had switched on warnings, Perl would have told you so.
> > >
> > > Change $cpname to $_ and it will work.  And, please, before you
> > > ask hundreds of people for help, take *one* close look at your code.
> > >
> > > Anno
> >
> > Will searching the solution, I realized that I posted a wrong version
> > of my script. I deleted it and now here is the good one.
>
> Oh boy...  Please take some more care with your postings.
>
> > ###############
> > #!C:\Perl\bin\perl.exe
> > #
> >
> > # Read the list of computer to run the script against
> > open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
> > exist.");
> >
> > # When a computer is unavailable, write it name to the log file.
> > open(OUTPUTFILE,">errors.txt");
> >
> > # For debugging purpose
> > open(DEBUGPING,">debug-ping.txt");
> > open(DEBUGCOMMANDS,">debug-commands.txt");
> >
> > system("cls");
> > while (<INPUTFILE>) {
> > 	$debugping =3D `ping -n 1 $_ 2>&1`;
> > 	if ( $? >> 8 =3D=3D 1 )
> > 		{
> > 		# That means the computers is unreachable. Exporting the name of such
> > computers to the log file.
> > 		print OUTPUTFILE "$_";
> > 		# chomp remove the \n from $_ variable to print it correctly to
> > STDOUT
> > 		chomp($_);
> > 		print  "\n\t\t\t $_ FAILED.";
> > 		}
> > 	else
> > 		{
> > 		# The computer is on the network. Let's run the commands against it.
> > 		open(DEBUGCOMMANDS,">>debug-commands.txt");
> > 		print DEBUGCOMMANDS "$_\n";
> > 		system ("REG QUERY \"\\\\$_\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
> > Explorer\\Main\" /v \"Start Page");
> >
> > 		# chomp remove the \n from $_ variable to print it correctly to
> > STDOUT
> > 		chomp($_);
> > 		print "\n$_ successfull.";
> > 		}
> > print DEBUGPING $debugping;
> > }
> >
> > ##########
> >
> > So to answer you Anno, this typo was not the source of my problem.
>
> Too bad you wasted everybody's time with it.
>
> > This
> > is the script causing me problem. $_ is not getting subsituted
> > correctly. But replacing $_ by a real computer name works fine.
>
> How do you know $_ is not substituted?  Have you printed the string
> instead of giving it to system(), so you can see what's actually in
> there?
>
> I have done so after making runnable code from your text.  I made $_
> contain "xxxxxxxxx" and it printed
>
>     REG QUERY "\\xxxxxxxxx\HKLM\SOFTWARE\MICROSOFT\Internet Explorer\Main"
>     /v "Start Page
>
> on a single line.  How is that not what you would expect?
>
> Anno


You put me on the way !! The problem comes from the new line character
at the end of $_ variable. In other word, the REG QUERY line is
splitted like this due to this character:

REG QUERY "\\xxxxxxxxx
\HKLM\SOFTWARE\MICROSOFT\Internet Explorer\Main"

So, I must remove this character from $_. Trying with chomp($_) is not
making it. But I think I can succeed using a temporar variable.

Sebastien



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

Date: 17 Jan 2007 07:03:44 -0800
From: "Seb" <sebastien.godier@gmail.com>
Subject: Re: Variable substitution
Message-Id: <1169046224.217172.104100@s34g2000cwa.googlegroups.com>


Seb a =E9crit :
> anno4...@radom.zrz.tu-berlin.de a =E9crit :
> > Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> > > anno4...@radom.zrz.tu-berlin.de a =E9crit :
> > > > Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
> > > > > Ok so here my complete script:
> > > >
> > > > [snipped except]
> > > >
> > > > > 		system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\In=
ternet
> > > >
> > > > The variable $cpname you try to interpolate is nowhere defined.  If
> > > > you had switched on warnings, Perl would have told you so.
> > > >
> > > > Change $cpname to $_ and it will work.  And, please, before you
> > > > ask hundreds of people for help, take *one* close look at your code.
> > > >
> > > > Anno
> > >
> > > Will searching the solution, I realized that I posted a wrong version
> > > of my script. I deleted it and now here is the good one.
> >
> > Oh boy...  Please take some more care with your postings.
> >
> > > ###############
> > > #!C:\Perl\bin\perl.exe
> > > #
> > >
> > > # Read the list of computer to run the script against
> > > open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
> > > exist.");
> > >
> > > # When a computer is unavailable, write it name to the log file.
> > > open(OUTPUTFILE,">errors.txt");
> > >
> > > # For debugging purpose
> > > open(DEBUGPING,">debug-ping.txt");
> > > open(DEBUGCOMMANDS,">debug-commands.txt");
> > >
> > > system("cls");
> > > while (<INPUTFILE>) {
> > > 	$debugping =3D `ping -n 1 $_ 2>&1`;
> > > 	if ( $? >> 8 =3D=3D 1 )
> > > 		{
> > > 		# That means the computers is unreachable. Exporting the name of su=
ch
> > > computers to the log file.
> > > 		print OUTPUTFILE "$_";
> > > 		# chomp remove the \n from $_ variable to print it correctly to
> > > STDOUT
> > > 		chomp($_);
> > > 		print  "\n\t\t\t $_ FAILED.";
> > > 		}
> > > 	else
> > > 		{
> > > 		# The computer is on the network. Let's run the commands against it.
> > > 		open(DEBUGCOMMANDS,">>debug-commands.txt");
> > > 		print DEBUGCOMMANDS "$_\n";
> > > 		system ("REG QUERY \"\\\\$_\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
> > > Explorer\\Main\" /v \"Start Page");
> > >
> > > 		# chomp remove the \n from $_ variable to print it correctly to
> > > STDOUT
> > > 		chomp($_);
> > > 		print "\n$_ successfull.";
> > > 		}
> > > print DEBUGPING $debugping;
> > > }
> > >
> > > ##########
> > >
> > > So to answer you Anno, this typo was not the source of my problem.
> >
> > Too bad you wasted everybody's time with it.
> >
> > > This
> > > is the script causing me problem. $_ is not getting subsituted
> > > correctly. But replacing $_ by a real computer name works fine.
> >
> > How do you know $_ is not substituted?  Have you printed the string
> > instead of giving it to system(), so you can see what's actually in
> > there?
> >
> > I have done so after making runnable code from your text.  I made $_
> > contain "xxxxxxxxx" and it printed
> >
> >     REG QUERY "\\xxxxxxxxx\HKLM\SOFTWARE\MICROSOFT\Internet Explorer\Ma=
in"
> >     /v "Start Page
> >
> > on a single line.  How is that not what you would expect?
> >
> > Anno
>
>
> You put me on the way !! The problem comes from the new line character
> at the end of $_ variable. In other word, the REG QUERY line is
> splitted like this due to this character:
>
> REG QUERY "\\xxxxxxxxx
> \HKLM\SOFTWARE\MICROSOFT\Internet Explorer\Main"
>
> So, I must remove this character from $_. Trying with chomp($_) is not
> making it. But I think I can succeed using a temporar variable.
>
> Sebastien


Yeah, here is a working version

######
#!C:\Perl\bin\perl.exe
#

# Read the list of computer to run the script against
open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
exist.");

# When a computer is unavailable, write it name to the log file.
open(OUTPUTFILE,">errors.txt");

# For debugging purpose
open(DEBUGPING,">debug-ping.txt");
open(DEBUGCOMMANDS,">debug-commands.txt");

system("cls");
while (<INPUTFILE>) {
	$debugping =3D `ping -n 1 $_ 2>&1`;
	if ( $? >> 8 =3D=3D 1 )
		{
		# That means the computers is unreachable. Exporting the name of such
computers to the log file.
		print OUTPUTFILE "$_";
		# chomp remove the \n from $_ variable to print it correctly to
STDOUT
		chomp($_);
		print  "\n\t\t\t $_ FAILED.";
		}
	else
		{
		# The computer is on the network. Let's run the commands against it.
		open(DEBUGCOMMANDS,">>debug-commands.txt");
		print DEBUGCOMMANDS "$_\n";
		$computer =3D $_;
		$computer =3D~ s/\s+$//;
		system ("REG QUERY
\"\\\\$computer\\HKLM\\SOFTWARE\\MICROSOFT\\Internet Explorer\\Main\"
/v \"Start Page\"");

		# chomp remove the \n from $_ variable to print it correctly to
STDOUT
		chomp($_);
		print "\n$_ successfull.";
		}
print DEBUGPING $debugping;
}

######

Many thanks Anno !!
Sebastien



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

Date: Wed, 17 Jan 2007 09:20:06 -0600
From: "Mumia W. (NOSPAM)" <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Variable substitution
Message-Id: <eolg56$hu3$2@aioe.org>

On 01/17/2007 08:32 AM, Seb wrote:
> anno4...@radom.zrz.tu-berlin.de a écrit :
>> Seb <sebastien.godier@gmail.com> wrote in comp.lang.perl.misc:
>>> Ok so here my complete script:
>> [snipped except]
>>
>>> 		system ("REG QUERY \"\\\\$cpname\\HKLM\\SOFTWARE\\MICROSOFT\\Internet
>> The variable $cpname you try to interpolate is nowhere defined.  If
>> you had switched on warnings, Perl would have told you so.
>>
>> Change $cpname to $_ and it will work.  And, please, before you
>> ask hundreds of people for help, take *one* close look at your code.
>>
>> Anno
> 
> Will searching the solution, I realized that I posted a wrong version
> of my script. I deleted it and now here is the good one.
> 
> ###############
> #!C:\Perl\bin\perl.exe
> #
> 
> # Read the list of computer to run the script against
> open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
> exist.");
> 
> # When a computer is unavailable, write it name to the log file.
> open(OUTPUTFILE,">errors.txt");
> 
> # For debugging purpose
> open(DEBUGPING,">debug-ping.txt");
> open(DEBUGCOMMANDS,">debug-commands.txt");
> 
> system("cls");
> while (<INPUTFILE>) {

Print out $_ before you try to ping it. I suspect that it has a newline 
sequence on the end of it.


> 	$debugping = `ping -n 1 $_ 2>&1`;
> 	if ( $? >> 8 == 1 )
> 		{
> 		# That means the computers is unreachable. Exporting the name of such
> computers to the log file. [...]


-- 
Windows Vista and your freedom in conflict:
http://www.badvista.org/


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

Date: Wed, 17 Jan 2007 09:58:56 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Variable substitution
Message-Id: <slrneqshu0.g96.tadmc@tadmc30.august.net>

Seb <sebastien.godier@gmail.com> wrote:

> #!C:\Perl\bin\perl.exe -w

> # Read the list of computer to run the script against
> open(INPUTFILE,"computers.txt") || die ("File $INPUTFILE does not
> exist.");


You do not read anything there, so the comment is misleading.

You should not ignore warning messages.

If the file does not exist, your error message will say:

   File  does not exist. at ...

If the file does exist, but fails for some other reason 
(eg. permission denied), your error message will say:

   File  does not exist. at ...

You should let perl give the reason why instead of guessing one
particlar reason on your own:

   my $fname = 'computers.txt';
   open(INPUTFILE, $fname) || die ("File '$fname' does not exist: $!");
                                                                  ^^
                                                                  ^^

> open(OUTPUTFILE,">errors.txt");


You should always, yes *always*, check the return value from open().


> 		print OUTPUTFILE "$_";


    print OUTPUTFILE $_;
or
    print OUTPUTFILE;


See:

   perldoc -q vars

       What’s wrong with always quoting "$vars"?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 42
*************************************


home help back first fref pref prev next nref lref last post