[30111] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1354 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 11 14:09:51 2008

Date: Tue, 11 Mar 2008 11:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 11 Mar 2008     Volume: 11 Number: 1354

Today's topics:
        ANNOUNCE: Text::CSV_XS 0.37 <h.m.brand@xs4all.nl>
    Re: class global variable?(from Perltoot document) xhoster@gmail.com
    Re: Fastest way to send file to browser xhoster@gmail.com
        How do I stop warnings from external packages? <justin.0803@purestblue.com>
    Re: How do I stop warnings from external packages? <devnull4711@web.de>
        How to send email with perl, or at least control Outloo <jack_posemsky@yahoo.com>
    Re: How to send email with perl, or at least control Ou <newsgroup898sfie@8439.e4ward.com>
    Re: list of day/month names in all locales <myicqKATTE@bakkegmx.net>
        perl html template error <jcharth@gmail.com>
    Re: perl html template error sheinrich@my-deja.com
    Re: perl html template error <glex_no-spam@qwest-spam-no.invalid>
    Re: Question on regex <zen13097@zen.co.uk>
    Re: regular expression with split goes wrong ? xhoster@gmail.com
    Re: regular expression with split goes wrong ? <jimsgibson@gmail.com>
    Re: Setting chmod <hjp-usenet2@hjp.at>
        timeout problem with Net::Telnet <gniagnia@gmail.com>
    Re: timeout problem with Net::Telnet <glex_no-spam@qwest-spam-no.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 11 Mar 2008 16:15:07 GMT
From: "H.Merijn Brand" <h.m.brand@xs4all.nl>
Subject: ANNOUNCE: Text::CSV_XS 0.37
Message-Id: <JxKqw6.1pnq@zorch.sf-bay.org>

  file: $CPAN/authors/id/H/HM/HMBRAND/Text-CSV_XS-0.37.tgz
  size: 81883 bytes
   md5: d54a0d6fdf50bc91291c5b358051b7b0

No action is required on your part
Request entered by: HMBRAND (H.Merijn Brand)
Request entered on: Tue, 11 Mar 2008 16:09:20 GMT
Request completed:  Tue, 11 Mar 2008 16:09:46 GMT

    Recent changes can be (re)viewed in the public GIT repository at
    git://repo.or.cz/Text-CSV_XS.git

2008-03-11  0.37 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * Copied GIT repo to public mirror
        * Fix leak / make meta info available to getline () + tests

2008-03-06  0.36 - H.Merijn Brand   <h.m.brand@xs4all.nl>

        * Updated ppport.h
        * auto-load IO::Handle when needed
        * Tested with all available perl builds, including a fresh
          threaded 5.11 (blead)

Enjoy, Have FUN! H.Merijn




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

Date: 11 Mar 2008 16:46:59 GMT
From: xhoster@gmail.com
Subject: Re: class global variable?(from Perltoot document)
Message-Id: <20080311124700.800$QN@newsreader.com>

jh3an <jh3ang@gmail.com> wrote:
> Please give me your advice :(
> I was reading perltoot document, and I got stuck the following class
> global variable concept.
> HELP!!
>
> Why global variable should be accessed by hash like this? :
> $self->{"_CENSUS"}

That isn't a global variable.  That is what they recommend using
*instead* of a global variable.

>
> Perltoot doc:
> Accessing Class Data
> It turns out that this is not really a good way to go about handling
> class data. A good scalable rule is that you must never reference
> class data directly from an object method. Otherwise you aren't
> building a scalable, inheritable class. The object must be the
> rendezvous point for all operations, especially from an object method.
> The globals (class data) would in some sense be in the "wrong" package
> in your derived classes. In Perl, methods execute in the context of
> the class they were defined in, not that of the object that triggered
> them. Therefore, namespace visibility of package globals in methods is
> unrelated to inheritance.(WHAT THE HECK HE IS TALKING ABOUT @.@??????)

Is there a particular part you are having trouble with, or is it the
entire paragraph?  If the latter, are you familiar with OO outside the
Perl context?


>
> Got that? Maybe not. Ok, let's say that some other class
> "borrowed" (well, inherited) the DESTROY method as it was defined
> above. When those objects are destroyed, the original $Census variable
> will be altered, not the one in the new class's package namespace.
> Perhaps this is what you want, but probably it isn't.
> (WHAT THE HECK HE IS TALKING ABOUT @.@??????)

He is stalking about class inheritance, and the problems with using
global variables therein.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: 11 Mar 2008 16:49:34 GMT
From: xhoster@gmail.com
Subject: Re: Fastest way to send file to browser
Message-Id: <20080311124936.584$dw@newsreader.com>

howa <howachen@gmail.com> wrote:
> In order to hidden the real path, I send the png file via CGI, e.g.
>
> ##############
>
> print "Content-type:image/png\n\n";
> my $file = "test.png";
>
> open INPUT_FILE, "$file" or die "Couldn't open file: $!";
> while( sysread(INPUT_FILE, $data, 10240) ) {
>         print $data;
> }
> close FILE;
>
> ##############
>
> Any faster/better method?

Take a step back and do some introspection on why you want to hide the
real path in the first place.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Tue, 11 Mar 2008 09:47:24 -0000
From: Justin C <justin.0803@purestblue.com>
Subject: How do I stop warnings from external packages?
Message-Id: <4f91.47d6552c.763be@zem>

I have a program with a 'require' line. The required item is another
program which puts a whole bunch of stock codes from an SQL database
into a hash, the has is what is used in the main program. I'm not
familiar with working this way (I have no idea how I wrote that in the
first place!).

The require is something like this:

package ProductCodes;
%codes {
    .
    .
    .
}

within the main program I have a line which generates a warning, the
line:

print $ProductCodes::codes{$req_delta};

The warning is: 

    Name "ProductCodes::codes" used only once: possible typo at

How can I stop this without turning off warnings?

Thank you for your suggestions.

	Justin.

-- 
Justin C, by the sea.


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

Date: Tue, 11 Mar 2008 11:54:45 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: How do I stop warnings from external packages?
Message-Id: <63n6nnF28h6p5U2@mid.individual.net>

Justin C wrote:
>
> The warning is: 
> 
>     Name "ProductCodes::codes" used only once: possible typo at
> 
> How can I stop this without turning off warnings?

Replace require by use or

{ no warnings 'once'; print $ProductCodes::codes{$req_delta}; }

Frank
-- 
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel


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

Date: Tue, 11 Mar 2008 08:39:50 -0700 (PDT)
From: Jack <jack_posemsky@yahoo.com>
Subject: How to send email with perl, or at least control Outlook Express
Message-Id: <1a721a3b-10d6-4774-9da6-03044d208ccd@s19g2000prg.googlegroups.com>

Hi for some reason I can send email and the target receives it with my
James mailserver via Outlook Express, but not via BLAT.  I am using
user/pass authentication.. can anyone point me to a script that works
and is simple for
1- send an email directly (problem with below is email never shows up
at destination)
OR 2-controlling Outlook Express to simply send an email (Undefined
subroutine &threads::new called at outlook_api_send.pl line 83.)

Neither of the examples work below
# 1 -
use Net::SMTP;

$smtp = Net::SMTP->new("smtp.xyz.com", Timeout => 5,Port =>25);

$ret = $smtp->auth("barry","password");

if ( ! $ret ) {
printf("Authentication failed\n");
} else {
printf("Authentication succeeded\n");
}

if ( ! $smtp ) {
die "Connection to SMTP server failed\n";
}


# Start a new email, and set the From address
$smtp->mail("barry@xyz.com");

# We're sending this to three people
@recipients = (
"goodboy@gmail.com"
);

$smtp->recipient(@recipients);

# Build the mail's headers, including the From: and To: address
$headers = <<"EOH";
From: Barry <barry@xyz.com>
To: Bill <goodboy@gmail.com>
Subject: This is a test
Date: Sun, 9 Mar 2008 00:03:46 +1100
EOH

# Build the content of the mail:
$message = <<"EOM";
This is a test. Please ignore this message.
EOM

# Now send it out:
$smtp->data($headers . "\n" . $message);

# Close the connection to the SMTP server.
$smtp->quit();

############################
#2 Error: (Undefined subroutine &threads::new called at
outlook_api_send.pl line 83)
# This script sends email via Outlook and MS Exchange and works around
the MS service pack security update
# So now you don't need outlook running and you don't have to press a
button to complete sending the mail.
# The code is based on one found at the perlmonks forum. The one on
the forum had some bugs and did not work for me
# as stated with the security prompts.
#
# Created by: me
#
# Usage:
#               perl domail.pl <options>
#               <options>: (M) = Mandetory; (O) = Optional
#
#               --email     (M) target email address in full
#               --to        (M) target name in full
#               --lead      (M) Leads name in full
#               --sr        (M) SR number
#               --cd        (M) Expected Date for Completion.
use strict;
use Thread;

use Win32::OLE;
use Win32::OLE qw(in with);
use Win32::GUI;
use Win32::GuiTest;
use IO::File;
use Getopt::Long;
use File::Basename;
use POSIX qw(tmpnam);


my $progname = basename($0);

## These variable will be used to store the command line argufromnts
my $email;      #= '';   # (M) target email address in full
my $to;         #= '';   # (M) target name in full
my $lead;       #= '';   # (M) Leads name in full
my $sr;         #= '';   # (M) SR number
my $cd;         #= '';   # (M) usernafrom to log into unix box

my $true    = 1;
my $false   = 0;


GetOptions ("email=s"       => \$email,
            "to=s"          => \$to,
            "lead=s"        => \$lead,
            "sr=s"          => \$sr,
            "cd=s"          => \$cd);

sub usage
{
    print("\nUsage:");
    print("\n\tperl domail.pl <options>");
    print("\n");
    print("\n\t<options>:   (M) = Mandetory; (O) = Optional");
    print("\n");
    print("\n\t--email      (M) target email address in full");
    print("\n\t--to         (M) target name in full");
    print("\n\t--lead       (M) Leads name in full");
    print("\n\t--sr         (M) SR number");
    print("\n\t--cd         (M) Expected Completion Date.");
    print("\n");
    print("\n\texample:");
    print("\n\tperl $progname -email \"receiver\@mycompany.com\" -to
\"Mr Receiver\" -lead \"Mr Lead\" -sr SR0000000 -cd \"Friday 13 May
2005\"");
    print("\n");
    print("\n");
}

sub chkOpts
{
    my $status = 1;
    unless (defined $email)     {print ("\nRecepient email is not
defined"); $status = 0;}
    unless (defined $to)        {print ("\nRecipient name is not
defined"); $status = 0;}
    unless (defined $lead)      {print ("\nLeads name is not
defined"); $status = 0;}
    unless (defined $sr)        {print ("\nSR in question is not
defined");  $status = 0;}
    unless (defined $cd)        {print ("\nExpected Completion Date is
not defined"); $status = 0;}

    if (!$status) {usage(); exit;}

}



my $thr1 = Thread->new(\&handleOutlookSecurity);

sub findSecurityWindow
# this method detects whether a security window popped up in Outlook.
If it is
# the case, it needs to be processed so that the script can be
executed.
# Else it'll pend.
{
   my $messageClass = "#32770";
   my $winName = "Microsoft Outlook";
   return Win32::GUI::FindWindow($messageClass,$winName);
}

sub clearSecurityWindow
# this method brings the security window on top of all the others,
hence focusing it
# and sends it a series of keystrokes in order to validate it.
{
   my $securityHandle = shift;

   while ($securityHandle!=Win32::GUI::GetForegroundWindow())
   {
      Win32::GUI::SetForegroundWindow($securityHandle);
      Win32::GUI::Enable($securityHandle);
   }

   # now send key sequence that will allow maximum time for code to
run
   # The sequence is as follows : initially the no button is
focused...
   # One tab brings us to cancel, another tab to the time tick box
   # a spacebar hit will tick the box. Then a tab will select the drop-
down
   # list in order for us to choose the time length. One more tab
brings us to Yes. A keypress on the End key will
   # select maximum time. Then a return key will validate our choice
   # 2 tabs - spacebar - 2 tab - one end - one return

   Win32::GuiTest::SendKeys("{TAB}");
   Win32::GuiTest::SendKeys("{TAB}");
   Win32::GuiTest::SendKeys("{SPACEBAR}");
   Win32::GuiTest::SendKeys("{TAB}");
   Win32::GuiTest::SendKeys("{TAB}");
   Win32::GuiTest::SendKeys("{END}");
   Win32::GuiTest::SendKeys("{ENTER}");
}

sub clearSecurityWindow2
# this method does the same as clearSecurityWindow but handles the
second security window.
{
   my $securityHandle = shift;

   while ($securityHandle!=Win32::GUI::GetForegroundWindow())
   {
      Win32::GUI::SetForegroundWindow($securityHandle);
      Win32::GUI::Enable($securityHandle);
   }
   Win32::GuiTest::SendKeys("{TAB}");
   Win32::GuiTest::SendKeys("{TAB}");
   Win32::GuiTest::SendKeys("{ENTER}");
}


sub handleOutlookSecurity
{
    # We don't need to sleep but just to be safe
    sleep 3;
    my $securityHandle = 0;

    while (not ($securityHandle)) # detects Outlook's popup window
that asks whether access should be granted to
    {
       $securityHandle = findSecurityWindow(); # wait for security
window to pop-up...
    }

    # window has been found - clear it
    clearSecurityWindow($securityHandle);

    # We need the "Yes" button to be active
    sleep 10;

    $securityHandle = 0;

    while (not ($securityHandle))
    {
       $securityHandle = findSecurityWindow(); # wait for security
window to pop-up...
    }

    # window has been found - clear it
    clearSecurityWindow2($securityHandle);
}

sub main
{

    # init OLE, COINIT_OLEINITIALIZE required when using MAPI.Session
objects
    Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
    die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError( );

    # Create a new MAPI session
    my $session = Win32::OLE->new('MAPI.Session')  or die "Failed to
create a new MAPI Session!";

    # Logon to server
    my $res = $session->Logon('MS Exchange
Settings','password','False');
    die "Could not log on to exchange server!" if ($res);

    # Create a new message
    my $msg = $session->Outbox->Messages->Add();

    # Add the recipient and resolve the address
    my $recipient = $msg->Recipients->Add();
    $recipient->{Name} = $email;
    $recipient->Resolve();

    # Add your text
    $msg->{Subject} = "DCA for SR $sr";
    $msg->{Text} = qq/
   Hello $to.

   As the Assessor\/Technical Authority for the SR $sr, you are
required to participate in its Defect Case Analysis.
   Please complete in the appropriate Perspective section(s) of the
DCA tool to the best of your knowledge and ability.


   The due date for completion of this task is $cd.

   Please work with your Lead for this SR, $lead, and be prepared to
answer relating questions if called by the Defect Council.

   Thanks you for your cooperation.





   Regards
   The Council

   Please note that this is an auto generated email. Contact your Lead
with any questions.
                 /;

    # Send the email
    # 1st argument = save copy of message
    # 2nd argument = allows user to change message w/dialog box before
sent
    # 3rd argument = parent window of dialog if 2nd argument is True
    $msg->Update();
    $msg->Send(1, 0, 0);

    # Log off
    $session->Logoff();

}

chkOpts();
main();



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

Date: Tue, 11 Mar 2008 14:08:54 -0400
From: Michael Goerz <newsgroup898sfie@8439.e4ward.com>
Subject: Re: How to send email with perl, or at least control Outlook Express
Message-Id: <63o05mF292ht8U1@mid.uni-berlin.de>

Jack wrote, on 03/11/2008 11:39 AM:
> Hi for some reason I can send email and the target receives it with my
> James mailserver via Outlook Express, but not via BLAT.  I am using
> user/pass authentication.. can anyone point me to a script that works
> and is simple for
> 1- send an email directly (problem with below is email never shows up
> at destination)

Does this help you?
http://www.physik.fu-berlin.de/~goerz/programs/mailpl/mailpl.html

Michael Goerz


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

Date: 11 Mar 2008 12:00:22 GMT
From: myicq <myicqKATTE@bakkegmx.net>
Subject: Re: list of day/month names in all locales
Message-Id: <Xns9A5E844F01420myicqKATTEbakkegmxne@62.243.74.163>

"John W. Krahn" <someone@example.com> wrote in news:%TaBj.75307$w57.69474
@edtnps90:


> perldoc perllocale
> perldoc I18N::Langinfo

Thanks for the information. But my request is for a Windows-based system.

Basically I need to find
    	- a list of available locales on my windows box
    	- a function that will list availbale day/month names for a given locale

Then I can iterate over all useful locales.



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

Date: Tue, 11 Mar 2008 07:24:18 -0700 (PDT)
From: joe <jcharth@gmail.com>
Subject: perl html template error
Message-Id: <716905d2-2ad9-4ec7-a03f-c9a33eea3109@59g2000hsb.googlegroups.com>

Hello, I am lerning the html template module and I keep get an error
on this line

$template->param(HEADINGS=>\@headings);


HTML::Template->output() : fatal error in loop output :
HTML::Template : Attempt to set nonexistent parameter 'heading' - this
parameter name doesn't match any declarations in the template file :
(die_on_bad_params => 1) at /usr/lib/perl5/site_perl/5.8.0/HTML/
Template.pm line 2997
 at ./one.cgi line 60

It looks like HEADINGS is not part of html::template any ideas on
which module has setting? or is it obsolete?


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

Date: Tue, 11 Mar 2008 08:03:17 -0700 (PDT)
From: sheinrich@my-deja.com
Subject: Re: perl html template error
Message-Id: <5e2734ed-e4cb-41ee-930e-ad5ea6e25db3@m44g2000hsc.googlegroups.com>

On Mar 11, 3:24 pm, joe <jcha...@gmail.com> wrote:
> Hello, I am lerning the html template module and I keep get an error
> on this line
>
> $template->param(HEADINGS=>\@headings);
>
> HTML::Template->output() : fatal error in loop output :
> HTML::Template : Attempt to set nonexistent parameter 'heading' - this
> parameter name doesn't match any declarations in the template file :
> (die_on_bad_params => 1) at /usr/lib/perl5/site_perl/5.8.0/HTML/
> Template.pm line 2997
>  at ./one.cgi line 60
>
> It looks like HEADINGS is not part of html::template any ideas on
> which module has setting? or is it obsolete?

You should give us a clue on how you build the content of @headings
and what your template placeholders look like.

The error suggests that your template might have a loop placeholder of
name HEADING (here you are defining HEADINGS instead) or one of the
field names is declared HEADING and this key might be missing from the
records (hash references) inside @headings.

steffen



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

Date: Tue, 11 Mar 2008 10:09:05 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: perl html template error
Message-Id: <47d6a092$0$87072$815e3792@news.qwest.net>

joe wrote:
> Hello, I am lerning the html template module and I keep get an error
> on this line
> 
> $template->param(HEADINGS=>\@headings);
> 
> 
> HTML::Template->output() : fatal error in loop output :
> HTML::Template : Attempt to set nonexistent parameter 'heading' - this
> parameter name doesn't match any declarations in the template file :
> (die_on_bad_params => 1) at /usr/lib/perl5/site_perl/5.8.0/HTML/
> Template.pm line 2997
>  at ./one.cgi line 60
> 
> It looks like HEADINGS is not part of html::template any ideas on
> which module has setting? or is it obsolete?

HTML::Template

Why do you think there is a default variable of HEADINGS?

You have to defined it in your template.

The error is saying that you have a template variable 'heading',
that you're not setting.  You can either set it to '', or read
the documentation to learn how to use 'die_on_bad_params'.


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

Date: 11 Mar 2008 12:05:01 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: Question on regex
Message-Id: <47d6756d$0$10633$fa0fcedb@news.zen.co.uk>

On Fri, 7 Mar 2008 17:22:15 -0800, szr <szrRE@szromanMO.comVE> wrote:
> > On Fri, 07 Mar 2008 14:19:49 -0800, cyrusgreats wrote:
> >
> > while (my $line = <DATA>) {
> 
>  Maybe make this:
> 
>    while (chomp(my $line = <DATA>)) {
> 
>  That will eat the trailing new line.

And yet it's not the right way to do it.

If you have warnings enabled (as you should), when you read the 
last line of the file, line is undefined and you will get
a warning:
  Use of uninitialized value in chomp at  ...

Better to write:
    while (my $line = <DATA>) {
        chomp $line;
        ...
    }



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

Date: 11 Mar 2008 16:54:43 GMT
From: xhoster@gmail.com
Subject: Re: regular expression with split goes wrong ?
Message-Id: <20080311125445.231$tP@newsreader.com>

Joost Diepenmaat <joost@zeekat.nl> wrote:
> jh3an <jh3ang@gmail.com> writes:
>
> > Here is mysterious code, please look:
> >
> > $x = '12aba34ba5';
> > @num = split /(a|b)+/, $x;
> >
> > now, @num has ('12','a','34','a','5').
> >
> > I don't understand.
> > I was expecting that @num would have '12','34','5'.
> > However, it is not.
>
> See perldoc -f split:
>
>  If the PATTERN contains parentheses, additional list elements
>  are created from each matching substring in the delimiter.


That really should say "If the PATTERN contains capturing parentheses,..."
                                                ^^^^^^^^^

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Tue, 11 Mar 2008 10:53:54 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: regular expression with split goes wrong ?
Message-Id: <110320081053544211%jimsgibson@gmail.com>

In article
<2e65c757-6a66-4edd-94de-e58afb20d6d8@u69g2000hse.googlegroups.com>,
Riad KACED <riad.kaced@gmail.com> wrote:

> I would propose the following for your case :
> @num = split /D+/,$x;

You left out one backslash:

  split /\D+/,$x;

> This will split with any a-zA-Z

Actually, \D stands for [^0-9], which is much larger than [a-zA-z] and
includes a lot of punctuation characters.

-- 
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com


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

Date: Tue, 11 Mar 2008 11:15:52 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Setting chmod
Message-Id: <slrnftcmuo.s1e.hjp-usenet2@hrunkner.hjp.at>

On 2008-03-10 18:59, Joost Diepenmaat <joost@zeekat.nl> wrote:
> John <John.Smith@invalid.com> writes:
>> OK I finally found what really works without using external library:
>>
>> $sec=open(TEKST,">test.txt");
>> chmod 0600,"test.txt";
>> binmode(TEKST);
>> print TEKST ""hello world";
>> close TEKST;
>>
>> 0600 everytime.
>
> Well, almost everytime: if someone else unlinks, overwrites, or moves
> the file (possibly replacing it with another) between the open() and
> chmod() call this won't do what you expect.

If that's a problem you shouldn't use open to open the file for writing
in the first place. Another user could create a symlink named "test.txt"
and you end up overwriting a completely different file.

Use sysopen with the O_EXCL flag instead. Or, if it's a temporary file
(the most common case where this is a problem) use the File::Temp
module.

	hp


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

Date: Tue, 11 Mar 2008 07:42:35 -0700 (PDT)
From: Mr_Noob <gniagnia@gmail.com>
Subject: timeout problem with Net::Telnet
Message-Id: <82107d12-f23d-4b20-a8ea-462d0b80549e@f63g2000hsf.googlegroups.com>

Hi all,

Here is my perl script that make a telnet connection with a windows2k3
box :


#!/usr/bin/perl -w
use strict;
use warnings;
use Net::Telnet ();
my $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die', Prompt =>
'/\$ $/i');

# telnet credentials
my $username = "administrator";
my $password = "mypass";
my $launcher = "c:\\\\my_bat_files\\\\test\\\\launcher.bat";
my $server = "myserver";

# Open telnet connection to $server
$telnet->open($server);
# telnet login/password
$telnet->login($username, $password);
# launch bat file
print $telnet->cmd($launcher);

But i have the following error :

"timed-out waiting for command prompt at scripts/Sanstat_launcher.pl
line 32"

I guess my "Prompt" isn't set correctly but can't find how to correct
this...
Here is how it looks like if i telnet my server manually :


$ telnet myserver
Trying 192.168.1.6...
Connected to myserver.mydomain.com.
Escape character is '^]'.
Welcome to Microsoft Telnet Service

login: administrator
password:

*===============================================================
Welcome to Microsoft Telnet Server.
*===============================================================
C:\Documents and Settings\Administrator>



thx in advance for helping


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

Date: Tue, 11 Mar 2008 10:15:15 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: timeout problem with Net::Telnet
Message-Id: <47d6a203$0$89864$815e3792@news.qwest.net>

Mr_Noob wrote:
> Hi all,
> 
> Here is my perl script that make a telnet connection with a windows2k3
> box :
> 
> 
> #!/usr/bin/perl -w
> use strict;
> use warnings;
> use Net::Telnet ();
> my $telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die', Prompt =>
> '/\$ $/i');

That's saying that you want a prompt that ends with a '$ '.

[...]
> I guess my "Prompt" isn't set correctly but can't find how to correct
> this...

You change the regular expression of the Prompt attribute above.

> Here is how it looks like if i telnet my server manually :
> 
> 
> $ telnet myserver
> Trying 192.168.1.6...
> Connected to myserver.mydomain.com.
> Escape character is '^]'.
> Welcome to Microsoft Telnet Service
> 


> login: administrator
> password:

Your prompt on the remote machine would be the 'login: ', then the 
'password: '.

Modify your Prompt to match what you're seeing on the remote machine.


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

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 1354
***************************************


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