[24924] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7174 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 24 14:09:30 2004

Date: Fri, 24 Sep 2004 11:05:13 -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           Fri, 24 Sep 2004     Volume: 10 Number: 7174

Today's topics:
        ANNOUNCE: Spreadsheet::WriteExcel 2.10 <jmcnamara@cpan.org>
    Re: Counting most frequently-occurring n-grams in a fil <_>
    Re: Counting most frequently-occurring n-grams in a fil <pinyaj@rpi.edu>
    Re: Counting most frequently-occurring n-grams in a fil <wksmith@optonline.net>
    Re: Help with my brute force method (Larry Felton Johnson)
    Re: Help with my brute force method (Larry Felton Johnson)
    Re: Help with my brute force method ctcgag@hotmail.com
    Re: Is it possible to embed perl inside a shell script  <shawn.corey@sympatico.ca>
    Re: Is it possible to embed perl inside a shell script  <nospamplease@cinci-solutions.com>
        MD5 of a string ? <vp@yahoo.com>
    Re: MD5 of a string ? <mritty@gmail.com>
    Re: MD5 of a string ? <jds@atavailcheck.com>
        ODBC Driver <mick.lan@laposte.net>
    Re: ODBC Driver <dwilga-MUNGE@mtholyoke.edu>
    Re: ODBC Driver <ouellmi@videotron.ca>
    Re: open3 and signals (Mike)
    Re: Printing an array of hash refs (Tony N.)
        Problem printing array content with CGI (Simon L)
    Re: Problem printing array content with CGI <shawn.corey@sympatico.ca>
    Re: Problem printing array content with CGI <noreply@gunnar.cc>
        telnet from perl (siddhartha mulpuru)
    Re: telnet from perl <postmaster@castleamber.com>
    Re: telnet from perl <nobull@mail.com>
    Re: Xah Lee's Unixism <albalmer@att.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Sep 2004 23:52:45 GMT
From: John McNamara <jmcnamara@cpan.org>
Subject: ANNOUNCE: Spreadsheet::WriteExcel 2.10
Message-Id: <I4JMJM.1Hyu@zorch.sf-bay.org>

======================================================================
ANNOUNCE

    Spreadsheet::WriteExcel version 2.10 has been uploaded to CPAN.

    http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel

======================================================================
NAME

    Spreadsheet::WriteExcel - Write formatted text and numbers to a
    cross-platform Excel binary file.

======================================================================
CHANGES

    2.10 September 23 2004 - Major

    + Added chart support via external templates.
      Added Chart.pm and add_chart_ext() method to Workbook object.
      Added /charts directory with examples and documentation

    + Added write_date_time() worksheet method for writing dates
      and times in Excel date format.
      Added date_time.pl example.

    + Added automatic Unicode handling via utf8 in perl 5.8 and
      later. Thanks Mark Fowler.
      Added several unicode_*.pl examples in different encodings.
      Thanks to Sean Burke for the sample encodings.

    + Added write_to_scalar.pl example in order to answer frequently
      asked question about writing an Excel file to a scalar.

======================================================================
DESCRIPTION

    The Spreadsheet::WriteExcel module can be used create a cross-
    platform Excel binary file. Multiple worksheets can be added to a
    workbook and formatting can be applied to cells. Text, numbers,
    formulas and hyperlinks and images can be written to the cells.

    The Excel file produced by this module is compatible with
    Excel 97, 2000, 2002 and 2003.

    The module will work on the majority of Windows, UNIX and
    Macintosh platforms. Generated files are also compatible with the
    Linux/UNIX spreadsheet applications Gnumeric and OpenOffice.org.

    This module cannot be used to read an Excel file. See
    Spreadsheet::ParseExcel or look at the main documentation for some
    suggestions.

    This module cannot be used to write to an existing Excel file.

======================================================================
SYNOPSIS

    To write a string, a formatted string, a number and a formula to
    the first worksheet in an Excel workbook called perl.xls:

        use Spreadsheet::WriteExcel;

        # Create a new Excel workbook
        my $workbook = Spreadsheet::WriteExcel->new("perl.xls");

        # Add a worksheet
        $worksheet = $workbook->add_worksheet();

        #  Add and define a format
        $format = $workbook->add_format();    # Add a format
        $format->set_bold();
        $format->set_color('red');
        $format->set_align('center');

        # Write a formatted and unformatted string
        $col = $row = 0;
        $worksheet->write($row, $col, "Hi Excel!", $format);
        $worksheet->write(1,    $col, "Hi Excel!");

        # Write a number and a formula using A1 notation
        $worksheet->write('A3', 1.2345);
        $worksheet->write('A4', '=SIN(PI()/4)');

======================================================================
REQUIREMENTS

    This module requires Perl 5.005 (or later), Parse::RecDescent and
    File::Temp

        http://search.cpan.org/search?dist=Parse-RecDescent
        http://search.cpan.org/search?dist=File-Temp


======================================================================
AUTHOR

    John McNamara (jmcnamara@cpan.org)

--




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

Date: Sat, 25 Sep 2004 00:07:20 +1000
From: "C3" <_>
Subject: Re: Counting most frequently-occurring n-grams in a file (or over multiple files)
Message-Id: <41542a17$0$23897$afc38c87@news.optusnet.com.au>

Hmm, seems to run on the command-line, but it produces no output for me.

"John W. Krahn" <someone@example.com> wrote in message 
news:AwQ4d.146861$XP3.70635@edtnps84...
> C3 wrote:
>> I'm looking for, or willing to write, a program that will take a list of 
>> files as command-line arguments, and then build up a frequency table of 
>> n-grams (individual bytes, or strings of 2 or more bytes) for all these 
>> files.
>>
>> e.g. ngram 4 file1.txt file2.txt
>>
>> would return the most frequently occurring sequences of 4 bytes over the 
>> two files.
>>
>> I am willing to go quick'n'dirty for this. I understand I need to build 
>> up a table of all the n-grams that exist in each file. Can someone help 
>> me get started on this?
>
> Well if it's quick'n'dirty that you want:
>
> perl -lne'BEGIN{$r="."x shift}$h{$1}++while/(?=($r))/g}{print for keys%h' 
> 4 file1.txt file2.txt
>
>
>
> John
> -- 
> use Perl;
> program
> fulfillment 




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

Date: Fri, 24 Sep 2004 11:16:35 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Counting most frequently-occurring n-grams in a file (or over multiple files)
Message-Id: <Pine.SGI.3.96.1040924111449.895234A-100000@vcmr-64.server.rpi.edu>

On Fri, 24 Sep 2004, it was written:

>I'm looking for, or willing to write, a program that will take a list of 
>files as command-line arguments, and then build up a frequency table of 
>n-grams (individual bytes, or strings of 2 or more bytes) for all these 
>files.
>
>e.g. ngram 4 file1.txt file2.txt
>
>would return the most frequently occurring sequences of 4 bytes over the two 
>files.

Open the file, read it in conveniently sized chunks, and for every group
of four characters, increment $ngram{$g}.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
  Senior Dean, Fall 2004    %  have long ago been overpaid?
RPI Corporation Secretary   %
http://japhy.perlmonk.org/  %    -- Meister Eckhart




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

Date: Fri, 24 Sep 2004 15:52:31 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: Counting most frequently-occurring n-grams in a file (or over multiple files)
Message-Id: <3pX4d.6629$6X1.9188385@news4.srv.hcvlny.cv.net>


"C3" <_> wrote in message
news:4153cc6b$0$20124$afc38c87@news.optusnet.com.au...
> I'm looking for, or willing to write, a program that will take a list
of
> files as command-line arguments, and then build up a frequency table
of
> n-grams (individual bytes, or strings of 2 or more bytes) for all
these
> files.
>
--snip--


Are n-grams restricted to characters on a single line or can they flow
onto the next line? (or even next file?)  In the latter case, are the
newline character(s) part of the n-gram?

Bill




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

Date: 24 Sep 2004 06:13:22 -0700
From: larryj@gsu.edu (Larry Felton Johnson)
Subject: Re: Help with my brute force method
Message-Id: <4ae7bf57.0409240513.1f88d7aa@posting.google.com>

krakle@visto.com (krakle) wrote in message 
> 
> Do you leave your home door wide open when you enter your house?

My intial off the cuff reply to this message didn't seem to post,
which is just as well, because I browsed back through the list to get
a representative sampling of the quality of your input.

My advice: it could use some work.  

First of all your statement above is garbled.  Is it in reference to
the code I posted?  If so it'd be good to clearly refer to the code. 
I don't normally comment on newsgroup/mailing list process issues, but
one obvious thing is that this is not a chat room, it's a language
related newsgroup.  If you have a critique of any code or discussion
of code I post, say so, but do it clearly.
I'm not thin skinned ... rip into my code and tear it apart.  Dazzle
me with your depth of knowledge of perl.
  
Metaphors are fine if they are clear and competent.  The statement
above is neither.

Second, do you ever post code examples or evaluation of code?  There's
nothing in the posts I've read to indicateMy intial off the cuff reply
to this message didn't seem to post, which is just as well, because I
browsed back through the list to get a representative sampling of the
quality of your input.

My advice: it could use some work.  

First of all your statement above is garbled.  Is it in reference to
the code I posted?  If so it'd be good to clearly refer to the code. 
I don't normally comment on newsgroup/mailing list process issues, but
one obvious thing is that this is not a chat room, it's a language
related newsgroup.  If you have a critique of any code or discussion
of code I post, say so, but do it clearly.
I'm not thin skinned ... rip into my code and tear it apart.  Dazzle
me with your depth of knowledge of perl.
  
Metaphors are fine if they are clear and competent.  The statement
above is neither.

Second, do you ever post code examples or evaluation of code?  There's
nothing in the posts I've read to indicate that you have even
rudimentary proficiency with perl.  There's nothing to indicate you
don't either, but there are a handful of people here whose posts I
read carefully (even if I don't like their stylistic traits or
nettiquette).  An orientation and focus on the problems and questions
at hand are one of the things which helps me devise my list of posters
worth reading.

I hope this is helpful.  Your volume of posts indicates a great deal
of energy.  If you'd work on channeling that energy in the service of
useful and constructive activity, it would serve both the perl
community and yourself much more effectively.

Now how about it?  How does the one line code above relate to my
earlier post? that you have even rudimentary proficiency with perl. 
There's nothing to indicate you don't either, but there are a handful
of people here whose posts I read carefully (even if I don't like
their stylistic traits or nettiquette).  An orientation and focus on
the problems and questions at hand are one of the things which helps
me devise my list of posters
worth reading.

I hope this is helpful.  Your volume of posts indicates a great deal
of energy.  If you'd work on channeling that energy in the service of
useful and constructive activity, it would serve both the perl
community and yourself much more effectively.

Now how about it?  How does the one line code above relate to my
earlier post?


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

Date: 24 Sep 2004 06:30:05 -0700
From: larryj@gsu.edu (Larry Felton Johnson)
Subject: Re: Help with my brute force method
Message-Id: <4ae7bf57.0409240530.5be4ed2c@posting.google.com>

krakle@visto.com (krakle) wrote in message 
> 
> Do you leave your home door wide open when you enter your house?

(And speaking of garbled, if the feedback from my post is any
indication, my paragraphs got mangled somewhere in the editing or
posting process.  Here is a second attempt:)

My intial off the cuff reply to this message didn't seem to post,
which is just as well, because I browsed back through the list to get
a representative sampling of the quality of your input.

My advice: it could use some work.  

First of all your statement above is garbled.  Is it in reference to
the code I posted?  If so it'd be good to clearly refer to the code. 
I don't normally comment on newsgroup/mailing list process issues, but
one obvious thing is that this is not a chat room, it's a language
related newsgroup.  If you have a critique of any code or discussion
of code I post, say so, but do it clearly.
I'm not thin skinned ... rip into my code and tear it apart.  Dazzle
me with your depth of knowledge of perl.
Metaphors are fine if they are clear and competent.  Your statement
above was neither.


Second, do you ever post code examples or evaluation of code?  There's
nothing in your posts I've read to indicate that you have even
rudimentary proficiency with perl.  There's nothing to indicate you
don't either, but there are a handful of people here whose posts I
read carefully (even if I don't like their stylistic traits or
nettiquette).  An orientation and focus on the problems and questions
at hand are one of the things which helps me devise my list of posters
worth reading.

I hope this is helpful.	 Your volume of posts indicates a great deal
of energy.
If you'd work on channeling that energy in the service of useful and
constructive activity, it would serve both the perl community and
yourself much more effectively.

So how about it?  How does your one line comment above relate to my
earlier post?


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

Date: 24 Sep 2004 15:36:50 GMT
From: ctcgag@hotmail.com
Subject: Re: Help with my brute force method
Message-Id: <20040924113650.421$Et@newsreader.com>

krakle@visto.com (krakle) wrote:
>
> Do you leave your home door wide open when you enter your house?

Yes.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Fri, 24 Sep 2004 07:33:10 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <fBT4d.29143$bL1.1295007@news20.bellglobal.com>

Tintin wrote:
8< snipped
> Actually, it's very easy to justify using the shell as there are plenty of 
> operations that are easier/better suited to a shell script.
> 
> 
> 

There are plenty of operations that are easier/better in Perl. Pattern 
matching and arithmetic are two examples.

	--- Shawn



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

Date: Fri, 24 Sep 2004 11:24:35 -0400
From: John Davison <nospamplease@cinci-solutions.com>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <10l8f1ji3mrrt9c@corp.supernews.com>

zzapper wrote:

> On 23 Sep 2004 19:33:28 GMT, wrote:
> 
> 
>>At 2004-09-23 03:15PM, zzapper <david@tvisnospam.co.uk> wrote:
>>
>>> Hi,
>>> Many years ago I used to embed AWK into a shell script, I've tried doing this with Perl with limited
>>> results
>>> 
>>
>>   #!/bin/bash
>>   perlscript='
>>       for $i (1..4) { $j="goat$i"; print " billy$j"; }
>>       # make the script as arbitrarily long as you like,
>>       # taking care to avoid single quotes
>>       my $string = q{a single quoted string};
>>       ...
>>   '
>>   fred=$(perl -e $perlscript)
>>   echo $fred
>>
>>   # or just write your perl code "inline"
>>   out=`perl -e '
>>       # perl code here
>>   '`
> 
> Glenn,
> That looks good, I wasn't sure before  if a Perl one-liner didn't have certain limits.
> But if anyone could suggest a method which frees me of the single quote constraint, does shell have
> a hereis method?
> 
> 
> zzapper (vim, cygwin, wiki & zsh)
> --
> 
> vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?"
> 
> http://www.vim.org/tips/tip.php?tip_id=305  Best of Vim Tips

perl<<EOF
# your perl code goes here
EOF

Of course you'll have to deal with shell escapes. :(

- john


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

Date: Fri, 24 Sep 2004 12:57:24 +0200
From: vp <vp@yahoo.com>
Subject: MD5 of a string ?
Message-Id: <4153fd78$0$4202$ba620e4c@news.skynet.be>

Hi,
How to get MD5 of a string in Perl please.
TIA,


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

Date: Fri, 24 Sep 2004 07:33:14 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: MD5 of a string ?
Message-Id: <cj10ma$t2g$1@misc-cct.server.rpi.edu>

vp wrote:

> How to get MD5 of a string in Perl please.

You should always check CPAN to see if there's a module you can use.  In 
this case, a search for 'MD5' gives you the Digest::MD5 module, along 
with a simple example:

use Digest::MD5 qw(md5);
$digest = md5($data);

For more information and options, see
http://search.cpan.org/~gaas/Digest-MD5-2.33/MD5.pm

Paul Lalli


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

Date: Fri, 24 Sep 2004 11:39:15 GMT
From: "Julia De Silva" <jds@atavailcheck.com>
Subject: Re: MD5 of a string ?
Message-Id: <DHT4d.101008$hZ3.5434@fe2.news.blueyonder.co.uk>

> Hi,
> How to get MD5 of a string in Perl please.
> TIA,

use Digest::MD5 qw( md5_base64 );
my $string = md5_base64 ( @data );





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

Date: Fri, 24 Sep 2004 12:04:01 +0200
From: Micla <mick.lan@laposte.net>
Subject: ODBC Driver
Message-Id: <cj0rjq$h61$1@s5.feed.news.oleane.net>


I'm a newcomer in Perl : I'm advised to use an ODBC driver to access a 
local database from a Perl Script.

Where can I get it, is there any tutorial doc for it ?

Thank's.

ML.


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

Date: Fri, 24 Sep 2004 09:16:00 -0400
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: ODBC Driver
Message-Id: <dwilga-MUNGE-7E9482.09160024092004@nap.mtholyoke.edu>

In article <cj0rjq$h61$1@s5.feed.news.oleane.net>,
 Micla <mick.lan@laposte.net> wrote:

> I'm a newcomer in Perl : I'm advised to use an ODBC driver to access a 
> local database from a Perl Script.
> 
> Where can I get it, is there any tutorial doc for it ?

One starting point is the documentation for DBI and DBD::ODBC, on 
cpan.perl.org .

-- 
Dan Wilga          dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **


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

Date: Fri, 24 Sep 2004 12:02:46 -0400
From: "Michele Ouellet" <ouellmi@videotron.ca>
Subject: Re: ODBC Driver
Message-Id: <KDX4d.67039$z74.690155@wagner.videotron.net>


> I'm a newcomer in Perl : I'm advised to use an ODBC driver to access a
> local database from a Perl Script.
>

DBI-DBD is an excellent approach. Alternately, if your platform is Windows
you might consider Win32::ODBC; perhaps easier, definitely not portable.

You should specify your OS and your DMBS.

Michèle.





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

Date: 24 Sep 2004 06:19:36 -0700
From: jmw_misc@hotmail.com (Mike)
Subject: Re: open3 and signals
Message-Id: <e64d100e.0409240519.6b91cc54@posting.google.com>

I came up with a solution using IO::Pipe and fork.
I then talk to the child with the pipe, he runs the program, and talks
back with the pipe.
The child is in a loop checking the pipe for more request, checking
the open3 program for r and e output. It also checks the status of the
parent process, which i store right after the fork before the loop. if
kill 0 $ppid returns 0, i try and shutdown the open3 program.
If anyone would like to see the code or know more, let me know.

I think open3 might fork also, but i cant seem to disassociate the
child process and only have access thru the the r,w,e handles.

Mike


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

Date: 24 Sep 2004 08:59:54 -0700
From: tnitzke@simpson.com (Tony N.)
Subject: Re: Printing an array of hash refs
Message-Id: <638483db.0409240759.235edacf@posting.google.com>

Joe Smith <Joe.Smith@inwap.com> wrote in message news:<gAQ4d.99101$MQ5.94815@attbi_s52>...
> Tony N. wrote:
> 
> > The hash ref array is populated using DBI and my SQL statement was
> > missing an outer join.  After I fixed that now I have the possibility
> > of null values coming the DB server.
> > 
> > 		print map {$row->{$_}?$row->{$_}:'' } sort keys %{$row};
> 
> That will print '0' as '', which is bad if 0 is a legitmate value.
> 
>    print map {(defined $row->{$_}) ? $row->{$_} : '' } sort keys %{$row};
> 
> 	-Joe

Good point.

Thanks,
Tony


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

Date: 24 Sep 2004 09:09:47 -0700
From: simon.low@pearson.com (Simon L)
Subject: Problem printing array content with CGI
Message-Id: <c75aaf9b.0409240809.5e916510@posting.google.com>

hi,

I have a script that calls another module
to exec a script, gets the output back in a array,
and prints out the content of the array using CGI.
If I run the script at the command line, it prints
everything from the array correctly.  However, if
I run it on the brower, the program runs but nothing
from the array gets displayed on the page. I have
struggled with it for a while, any insight would be
greatly appreciated.

   my $line;
   my (@stdout, @stderr);

   # $program_name is another Perl script
   my $scr = '/user/ice/htdocs/' . $program_name;

   # command to be sent to another program to exec

   my @cmd = ($scr, '-mode', $Mode, '-U', 'xxx', '-P', 'xxx',  '-App', $AppName);

   # send for exec and gets its STDOUT and STDERR back using 
   # @stdout and @stderr

   my $rc = ForkAndReadStdoutStderr(\@stdout, \@stderr, @cmd);
   if ($rc < 0)
        { print $Cgi->p($ICE::Fork::ERROR) }
   if ($rc > 0)
        { print $Cgi->p("@cmd FAILED!  stdout=@stdout;stderr=@stderr") }

   print header('text/plain');

   foreach $line (@stdout)
   {
       print $line;
   }
		
My temporary solution now is to send the output
of the script that I system() to a file and
use "print redirect()" to display the file.

Thanks,
SL


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

Date: Fri, 24 Sep 2004 12:39:01 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Problem printing array content with CGI
Message-Id: <Z3Y4d.29331$bL1.1349299@news20.bellglobal.com>

Hi,

If a CGI works from a command line but not when called by a web server 
then 95% of the time it's a problem with permissions. Check _all_ files 
including the data files.

	--- Shawn

Simon L wrote:
> hi,
> 
> I have a script that calls another module
> to exec a script, gets the output back in a array,
> and prints out the content of the array using CGI.
> If I run the script at the command line, it prints
> everything from the array correctly.  However, if
> I run it on the brower, the program runs but nothing
> from the array gets displayed on the page. I have
> struggled with it for a while, any insight would be
> greatly appreciated.
> 
>    my $line;
>    my (@stdout, @stderr);
> 
>    # $program_name is another Perl script
>    my $scr = '/user/ice/htdocs/' . $program_name;
> 
>    # command to be sent to another program to exec
> 
>    my @cmd = ($scr, '-mode', $Mode, '-U', 'xxx', '-P', 'xxx',  '-App', $AppName);
> 
>    # send for exec and gets its STDOUT and STDERR back using 
>    # @stdout and @stderr
> 
>    my $rc = ForkAndReadStdoutStderr(\@stdout, \@stderr, @cmd);
>    if ($rc < 0)
>         { print $Cgi->p($ICE::Fork::ERROR) }
>    if ($rc > 0)
>         { print $Cgi->p("@cmd FAILED!  stdout=@stdout;stderr=@stderr") }
> 
>    print header('text/plain');
> 
>    foreach $line (@stdout)
>    {
>        print $line;
>    }
> 		
> My temporary solution now is to send the output
> of the script that I system() to a file and
> use "print redirect()" to display the file.
> 
> Thanks,
> SL



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

Date: Fri, 24 Sep 2004 19:19:08 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Problem printing array content with CGI
Message-Id: <2rj362F19gourU1@uni-berlin.de>

Shawn Corey wrote:
> If a CGI works from a command line but not when called by a web
> server then 95% of the time it's a problem with permissions.

Relative paths is a rather common cause as well.

> Check _all_ files including the data files.

And ensure that they are called with full paths.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 24 Sep 2004 08:40:46 -0700
From: justkule@yahoo.com (siddhartha mulpuru)
Subject: telnet from perl
Message-Id: <78e9cb22.0409240740.45b6b5da@posting.google.com>

I use this NET::TELNET module to login into a telnet session.. THis is
the code

#!/usr/bin/perl
use CGI;

$frm = new CGI;

$unix_box = $frm->param('unix_box');

$username = $frm->param('username');

$password = $frm->param('password');

#$unix_box = "xxxx.xxx.xxx";

#$username = "xxxxxx";

#$password = "xxxxxxxx";

my $prmpt = '/[\w().-]*[\$#>:.]\s?(?:\(enable\))?\s*$/'; 
$telnet = new Net::Telnet ( Timeout=>20, Prompt => $prmpt,
"Dump_log"   => "dump_log",  
Errmode=>'die');
use Net::Telnet;
$telnet->open($unix_box);
$telnet->waitfor('/login:/i');
$telnet->print($username);
$telnet->waitfor('/Enter SecurID PASSCODE:/i');
$telnet->print($password);
$telnet->waitfor('/.+:\/.+\/.+>/i');
@lines= $telnet->cmd("who"); 
#print STDOUT @lines;

print "Content-type: text/html\n\n";

print "
@lines
";


$telnet->close;

When i run this script from the command line it works fine. But when i
run this as a post from a form with values for username,password and
unix box it does not work.

Please advise

Thanks
Sid


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

Date: 24 Sep 2004 15:59:58 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: telnet from perl
Message-Id: <Xns956E6FE1E7720castleamber@130.133.1.4>

justkule@yahoo.com (siddhartha mulpuru) wrote in 
news:78e9cb22.0409240740.45b6b5da@posting.google.com:

> When i run this script from the command line it works fine. But when i
> run this as a post from a form with values for username,password and
> unix box it does not work.

describe "does not work"

Check the error_log of the webserver, anything there?

the use Net::Telnet is at a weird place, put it higher.

open - connect to port on remote host
"On success 1 is returned. On time-out or other connection failures, the 
error mode action is performed. See errmode()."

maybe some error trapping?....

-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html


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

Date: Fri, 24 Sep 2004 17:09:27 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: telnet from perl
Message-Id: <cj1gjd$6i8$1@sun3.bham.ac.uk>

siddhartha mulpuru wrote:

> When i run this script from the command line it works fine. But when i
> run this as a post from a form with values for username,password and
> unix box it does not work.

"does not work" is a red flag phrase.  Whenever you find yourself typing 
it you should immediately delete it and instead replace it with an 
explaination of excatly in what way and at what point does it fails.

(You may have to add diagnostic prints to STDERR and/or look in error 
logs to determine this).

You should never, ever, dream of hitting send on a question to Usenet 
where the total description you give of the failure you are experiencing 
  reads "it does not work".

See also FAQ: "My CGI script runs from the command line but not the
browser."



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

Date: Fri, 24 Sep 2004 08:42:33 -0700
From: Alan Balmer <albalmer@att.net>
Subject: Re: Xah Lee's Unixism
Message-Id: <ref8l0t9e5mbga1jivi365jrug7aip5l20@4ax.com>

On Tue, 21 Sep 2004 08:44:20 -0000, SM Ryan
<wyrmwif@tango-sierra-oscar-foxtrot-tango.fake.org> wrote:

A classic resort to name-calling, indicating that (1) he knows he's
wrong, (2) he's not worth corresponding with.

<plonk>

-- 
Al Balmer
Balmer Consulting
removebalmerconsultingthis@att.net


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

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 V10 Issue 7174
***************************************


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