[17826] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5246 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 4 22:18:43 2001

Date: Thu, 4 Jan 2001 19:18:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978664691-v9-i5246@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 Jan 2001     Volume: 9 Number: 5246

Today's topics:
    Re: regular expr. <dim@drum.myweb.nl>
    Re: regular expr. <bart.lateur@skynet.be>
    Re: Regular expression Stuff? nobull@mail.com
    Re: Regular expression Stuff? (mountainarts)
        regx question tunneling@my-deja.com
        regx question tunneling@my-deja.com
    Re: regx question <uri@sysarch.com>
        Retrieving HTML... tohann@my-deja.com
    Re: Retrieving HTML... (Tad McClellan)
    Re: Retrieving HTML... tohann@my-deja.com
    Re: Retrieving HTML... <tony_curtis32@yahoo.com>
    Re: Retrieving HTML... tohann@my-deja.com
    Re: Retrieving HTML... <nospam@bml.uk-mart.co.uk>
    Re: Retrieving HTML... <joe+usenet@sunstarsys.com>
    Re: Retrieving HTML... <mischief@velma.motion.net>
    Re: Retrieving HTML... (Garry Williams)
    Re: Retrieving HTML... tohann@my-deja.com
    Re: Retrieving HTML... <mtaylorlrim@my-deja.com>
    Re: Retrieving HTML... <fozz@iodynamics.com>
        rsh/cvs problem hedley_s@my-deja.com
    Re: rsh/cvs problem (Richard Zilavec)
    Re: rsh/cvs problem <zach@zachlipton.com>
    Re: rsh/cvs problem hedley_s@my-deja.com
    Re: rsh/cvs problem (Chris Fedde)
    Re: rsh/cvs problem hedley_s@my-deja.com
        Script to disconnect users on a dialup system (dolphin)
    Re: Script to disconnect users on a dialup system (Chris Fedde)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 30 Dec 2000 00:32:29 +0100
From: "Dim" <dim@drum.myweb.nl>
Subject: Re: regular expr.
Message-Id: <92j5tm$sr4$1@cyan.nl.gxn.net>


"Sven Franke" <snefsite@hotmail.com> wrote in message
news:91va9v$flc$1@enterprise.cistron.net...
> Hi,
>
> I have a string that contains a lot of text. In the text there is a line
> like:
>
> [BLA=qwert-foo]
>
> I want to extract this line and use the text behind the =sign. How can
this
> be done. I've wrestled with m/xx/, but I can't get it right.
>
> Can someone help me out?
> (I already tried the help on matchingpatterns, but I can't seem to get it
> work.....)
>
$string="some text here [BLA=qwert-foo] and something else here";
$string=~m/\[[^\]]+=(.+)\]/;    # match everything after = if it's
etween[ and ]
print $1;

Regards,

DIM




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

Date: Sat, 30 Dec 2000 01:08:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: regular expr.
Message-Id: <e4dq4tc490ul9rtgnrb7n4v2vj8k4dk1vh@4ax.com>

Sven Franke wrote:

>I have a string that contains a lot of text. In the text there is a line
>like:
>
>[BLA=qwert-foo]
>
>I want to extract this line and use the text behind the =sign. How can this
>be done. I've wrestled with m/xx/, but I can't get it right.

You say there's a "line" containing text like this? Is that, beginning
of string, or newline just in front of it, and followed by newline or
end of string?

Then you should use the /^/ and /$/ anchors, combined with the /m
modifier.

	/^\[(\w+)=(\S+)\]$/m and print "Key = $1, value = '$2'\n";

If you can have more than one of these lines, and you want to catch them
all, try

	@pairs = /^\[(\w+)=(\S+)\]$/mg;

This will give two array items per match. You can populate a hash with
it, if you like.

-- 
	Bart.


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

Date: 29 Dec 2000 17:44:34 +0000
From: nobull@mail.com
Subject: Re: Regular expression Stuff?
Message-Id: <u9zohf3ywt.fsf@wcl-l.bham.ac.uk>

jaya <jaya_j_k@hotmail.com> writes:

> Now the array contains:
> $a1 = 10;
> $MY_MMI=34, $Te11=$1as83a, $x4585=abcd, $B =20;

Is that 2 entries or 5?  Please be explicit.  The easy way to be
explicit is to write in Perl:

@array = ( '$a1 = 10;',
           '$MY_MMI=34, $Te11=$1as83a, $x4585=abcd, $B =20;'
) ;

> I gave the following condition:
> (/^\$\w*\s*=/)
> 
> This is giving me all variables (i.e., $MY_MMI=34, $Te11=$1as83a, 
> $x85=abcd)

Eh, no that can't be true.  A condition, by it's very nature, gives
you true or false. I suspect the "This" in the above sentence
actually refers to some code you've not shown us.

> 
> But skipping the $B =20 and $a1 = 10 
> as they contains the spaces.
> 
> I want that variables also.
> 
> Will anyone help me out, please.

I think you need to be a lot clearer about what it is you want to do
and what it is that you have done.

If in difficulty produce a minimal, self-contained, strict,
tested, warning-free script that runs and reproduces the behaviour you
are having trouble with.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 29 Dec 2000 19:36:38 GMT
From: mountainarts@altavista.com (mountainarts)
Subject: Re: Regular expression Stuff?
Message-Id: <3a4ce697.18797888@news.dreamsoft.com>

jaya <jaya_j_k@hotmail.com> wrote:

>Hello,
>
>My problem is:
>
>In one file I have
>
>#Some Statements
>$x = 20
>#Some Statements
>screen $a1 = 10;
>screen $MY_MMI=34, $Te11=$1as83a, $x4585=abcd, $B =20;
>#Some Statements
>
>I'm filtering all the screen related lines and storing in an array. Now 
>the array contains:
>$a1 = 10;
>$MY_MMI=34, $Te11=$1as83a, $x4585=abcd, $B =20;
>
>Now I want to write the vairables and values in some different file.
>
>I gave the following condition:
>(/^\$\w*\s*=/)
>
>This is giving me all variables (i.e., $MY_MMI=34, $Te11=$1as83a, 
>$x85=abcd)
>
>But skipping the $B =20 and $a1 = 10 
>as they contains the spaces.
>
>I want that variables also.
>
>Will anyone help me out, please.
>
>Thanks in advance,
>
>Regards,
>Jaya

try this


#!/usr/bin/perl -w
use Strict;

$in_file = "file1";
$out_file = "output_from_file1";

unlink $out_file;                  # clean up old output

open (IN,"<$in_file") || die "cannot open $in_file $!\n";
open (OUT,">$out_file") || die "cannot open $out_file $!\n";
while ( <IN> ) {
    chomp;                              # remove record delimiter
    if ( m/^screen/ ) {            # got screen item
        s/^screen//;                 # remove marker;
        s/;//;                                # remove semicolon
        @items = split(/,/,$_);    # create array of items
        foreach $item ( @items ) {
            print OUT "$item\n";   # write item to file
            print  "$item written to $out_file\n";      
                                  # print to screen for debug
        }
    }
    else {
        print "Skipping $_ \n";
    }
}
close IN;
close OUT;





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

Date: Tue, 02 Jan 2001 22:14:09 GMT
From: tunneling@my-deja.com
Subject: regx question
Message-Id: <92tjra$m1p$1@nnrp1.deja.com>

A working search and replace expression is:
$_ =~ s/today\=(\S*)1/today\=$1 2/ig ;

A sample subject file is:
today=tx1
today=t1
sssssssssss=tx1

I get the results:
today=tx 2
today=t 2
sssssssssss=tx1

I desire the results:
today=tx2
today=t2
sssssssssss=tx1

I cannot figure out how to get around the
whitespace between $1 and 2, if I move the 2 next
to the $1 is looks for the 12th buffered search
expression, which obviously does not exist.
Regards,
Jason


Sent via Deja.com
http://www.deja.com/


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

Date: Tue, 02 Jan 2001 22:14:08 GMT
From: tunneling@my-deja.com
Subject: regx question
Message-Id: <92tjr7$m1o$1@nnrp1.deja.com>

A working search and replace expression is:
$_ =~ s/today\=(\S*)1/today\=$1 2/ig ;

A sample subject file is:
today=tx1
today=t1
sssssssssss=tx1

I get the results:
today=tx 2
today=t 2
sssssssssss=tx1

I desire the results:
today=tx2
today=t2
sssssssssss=tx1

I cannot figure out how to get around the
whitespace between $1 and 2, if I move the 2 next
to the $1 is looks for the 12th buffered search
expression, which obviously does not exist.
Regards,
Jason


Sent via Deja.com
http://www.deja.com/


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

Date: Tue, 02 Jan 2001 22:25:51 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: regx question
Message-Id: <x7u27h8uc0.fsf@home.sysarch.com>

>>>>> "t" == tunneling  <tunneling@my-deja.com> writes:

  t> A working search and replace expression is:

  t> $_ =~ s/today\=(\S*)1/today\=$1 2/ig ;

no need for $_ =~ as that is the default for //.

no need to backwhack =. it is not a regex metachar. and no need to
backwahck it in the replacement string which is almost just a pure
double quote expression.

  t> I cannot figure out how to get around the whitespace between $1 and
  t> 2, if I move the 2 next to the $1 is looks for the 12th buffered
  t> search expression, which obviously does not exist.

you can delimit any scalar interpolation by putting {} around the var
name.

	s/today=(\S*)1/today=${1}2/ig ;

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 29 Dec 2000 18:43:25 GMT
From: tohann@my-deja.com
Subject: Retrieving HTML...
Message-Id: <92im0c$oht$1@nnrp1.deja.com>

Hello.  Is there any way I can retrieve the HTML source of a .cgi
program via Perl?  It's safe to assume the .cgi is written in C.  Is
there a tool in CGI.pm or anything else that will allow me to do this?

Thanks in advance...
Trent O.


Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 29 Dec 2000 12:12:28 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Retrieving HTML...
Message-Id: <slrn94phfs.vv.tadmc@magna.metronet.com>

tohann@my-deja.com <tohann@my-deja.com> wrote:

>Hello.  Is there any way I can retrieve the HTML source of a .cgi
>program via Perl?  


Huh?

CGI programs are written in a programming language of some kind.

HTML is not a programming language of some kind, it is merely data.

I dunno what you mean by "HTML source of a .cgi program".

Your question does not make any sense...


>It's safe to assume the .cgi is written in C.  


Did you mean to say "C source" instead then?


>Is
>there a tool in CGI.pm or anything else that will allow me to do this?
                                                                  ^^^^

What is "this"?

If you want to get the source to a CGI program, you cannot do it
if the web server is configured correctly.


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


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

Date: Fri, 29 Dec 2000 19:52:05 GMT
From: tohann@my-deja.com
Subject: Re: Retrieving HTML...
Message-Id: <92iq13$rsh$1@nnrp1.deja.com>

Ok, let me try to explain this another way then.  When you hit a .cgi
program in a browser, the page is displayed.  Do a view source and you
see the HTML code.  That is what I want, the HTML code for the page.  I
don't know if CGI.pm or the LWP library have anything of use.  Is this
even possible in Perl?



In article <slrn94phfs.vv.tadmc@magna.metronet.com>,
  tadmc@metronet.com (Tad McClellan) wrote:
> tohann@my-deja.com <tohann@my-deja.com> wrote:
>
> >Hello.  Is there any way I can retrieve the HTML source of a .cgi
> >program via Perl?
>
> Huh?
>
> CGI programs are written in a programming language of some kind.
>
> HTML is not a programming language of some kind, it is merely data.
>
> I dunno what you mean by "HTML source of a .cgi program".
>
> Your question does not make any sense...
>
> >It's safe to assume the .cgi is written in C.
>
> Did you mean to say "C source" instead then?
>
> >Is
> >there a tool in CGI.pm or anything else that will allow me to do
this?
>                                                                   ^^^^
>
> What is "this"?
>
> If you want to get the source to a CGI program, you cannot do it
> if the web server is configured correctly.
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas
>


Sent via Deja.com
http://www.deja.com/


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

Date: 29 Dec 2000 14:14:23 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Retrieving HTML...
Message-Id: <87wvcj7zog.fsf@limey.hpcc.uh.edu>



[ please put your new text *after* what you are replying to ]

>> On Fri, 29 Dec 2000 19:52:05 GMT,
>> tohann@my-deja.com said:

> Ok, let me try to explain this another way then.  When you hit a
> .cgi program in a browser, the page is displayed.  Do a view source

More precisely: when you follow a link in a browser which leads to a
connection to a web server which is configured to run a program
(through the CGI interface) and that program generates the return
headers and content...

Remember, the CGI program does not do anything in the browser, the
browser just sends a request to a server which then happens to invoke
an external program to handle that request.

> and you see the HTML code.  That is what I want, the HTML code for
> the page.  I don't know if CGI.pm or the LWP library have anything

So you want to "follow" a URL and collect the returned HTML from the
server.

> of use.  Is this even possible in Perl?

Yes.  Your interest in the CGI aspect at the other end of the link (on
the server) is a red herring and I think that is what was causing some
confusion.  A browser or other user-agent has no knowledge (no sure
knowledge anyway) of how a particular URL represents its content
(file, CGI program, PHP, servlet, etc).

The LWP stuff is what you want.  See "perldoc lwpcook" for examples.
LWP::Simple should be enough to get you started.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Fri, 29 Dec 2000 21:01:18 GMT
From: tohann@my-deja.com
Subject: Re: Retrieving HTML...
Message-Id: <92iu2q$vdb$1@nnrp1.deja.com>

In article <87wvcj7zog.fsf@limey.hpcc.uh.edu>,
  Tony Curtis <tony_curtis32@yahoo.com> wrote:
>
>
> [ please put your new text *after* what you are replying to ]
>
> >> On Fri, 29 Dec 2000 19:52:05 GMT,
> >> tohann@my-deja.com said:
>
> > Ok, let me try to explain this another way then.  When you hit a
> > .cgi program in a browser, the page is displayed.  Do a view source
>
> More precisely: when you follow a link in a browser which leads to a
> connection to a web server which is configured to run a program
> (through the CGI interface) and that program generates the return
> headers and content...
>
> Remember, the CGI program does not do anything in the browser, the
> browser just sends a request to a server which then happens to invoke
> an external program to handle that request.
>
> > and you see the HTML code.  That is what I want, the HTML code for
> > the page.  I don't know if CGI.pm or the LWP library have anything
>
> So you want to "follow" a URL and collect the returned HTML from the
> server.
>
> > of use.  Is this even possible in Perl?
>
> Yes.  Your interest in the CGI aspect at the other end of the link (on
> the server) is a red herring and I think that is what was causing some
> confusion.  A browser or other user-agent has no knowledge (no sure
> knowledge anyway) of how a particular URL represents its content
> (file, CGI program, PHP, servlet, etc).
>
> The LWP stuff is what you want.  See "perldoc lwpcook" for examples.
> LWP::Simple should be enough to get you started.
>
> hth
> t
> --
> Eih bennek, eih blavek.
>


That was exactly what I need.  Thanks Tony...




Sent via Deja.com
http://www.deja.com/


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

Date: Fri, 29 Dec 2000 21:19:00 -0000
From: "Mark Longhurst" <nospam@bml.uk-mart.co.uk>
Subject: Re: Retrieving HTML...
Message-Id: <tc736.16141$Yy.441249@news2-win.server.ntlworld.com>


<tohann@my-deja.com> wrote in message news:92iq13$rsh$1@nnrp1.deja.com...
> Ok, let me try to explain this another way then.  When you hit a .cgi
> program in a browser, the page is displayed.  Do a view source and you
> see the HTML code.  That is what I want, the HTML code for the page.  I
> don't know if CGI.pm or the LWP library have anything of use.  Is this
> even possible in Perl?
>

Maybe I'm misunderstanding you, but it seems to me that you have answered
your own question here.

As you say, all you need to do is execute the .cgi script, go to view source
on the resulting page, and you've GOT the HTML source of the page.  Since
this is displayed in Notepad (under Win.) or I presume some other text
editor under other O/S all you need to do then is save it with a .htm file
extension, and you're there.

Or was this not what you wanted?

Mark Longhurst




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

Date: 29 Dec 2000 16:47:50 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Retrieving HTML...
Message-Id: <m3hf3m7vcp.fsf@mumonkan.sunstarsys.com>

"Mark Longhurst" <nospam@bml.uk-mart.co.uk> writes:

> <tohann@my-deja.com> wrote in message news:92iq13$rsh$1@nnrp1.deja.com...
> > Ok, let me try to explain this another way then.  When you hit a .cgi
> > program in a browser, the page is displayed.  Do a view source and you
> > see the HTML code.  That is what I want, the HTML code for the page.  

You mean you want the browser to display the content of the script output
in plaintext rather that render it as HTML? If so, just change the 
Content-Type to text/plain in your cgi program (instead of using text/html).

> > I don't know if CGI.pm or the LWP library have anything of use.  Is this
> > even possible in Perl?  > >

See the CGI documentation for info on setting the content-type header: 
something like:

 print $q->header(-type  =>  'text/plain', ...

HTH
-- 
Joe Schaefer


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

Date: Fri, 29 Dec 2000 21:49:13 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Retrieving HTML...
Message-Id: <t4q1mp2f06hlc7@corp.supernews.com>

Mark Longhurst <nospam@bml.uk-mart.co.uk> wrote:

> <tohann@my-deja.com> wrote in message news:92iq13$rsh$1@nnrp1.deja.com...
>> Ok, let me try to explain this another way then.  When you hit a .cgi
>> program in a browser, the page is displayed.  Do a view source and you
>> see the HTML code.  That is what I want, the HTML code for the page.  I
>> don't know if CGI.pm or the LWP library have anything of use.  Is this
>> even possible in Perl?
>>

> Maybe I'm misunderstanding you, but it seems to me that you have answered
> your own question here.

> As you say, all you need to do is execute the .cgi script, go to view source
> on the resulting page, and you've GOT the HTML source of the page.  Since
> this is displayed in Notepad (under Win.) or I presume some other text
> editor under other O/S all you need to do then is save it with a .htm file
> extension, and you're there.

I'm thinking he wants to programmatically do the same sort of thing.
What he needs to do is to grab the URL of the CGI with the proper
parameters and process the page sent back. LWP or any other solution
for grabbing a web page as a client should be able to do this if they
have any support for CGI.

Chris

-- 
Christopher E. Stith

Even in the worst of times, there is always someone who's never had it better.
Even in the best of times, there is always someone who's never had it worse.



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

Date: Sat, 30 Dec 2000 01:29:23 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Retrieving HTML...
Message-Id: <TTa36.469$ld.30970@eagle.america.net>

On Fri, 29 Dec 2000 21:49:13 -0000, Chris Stith
<mischief@velma.motion.net> wrote:

>I'm thinking he wants to programmatically do the same sort of thing.
>What he needs to do is to grab the URL of the CGI with the proper
>parameters and process the page sent back. LWP or any other solution
>for grabbing a web page as a client should be able to do this if they
>have any support for CGI.
          ^^^^^^^^^^^^^^^

What on earth does that mean?  See Tony Curtis' follow-up.  It seems
that you may be confused, too.  

The rest of your comment makes sense: use LWP to retrieve the URL
_content_.  

-- 
Garry Williams


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

Date: Sun, 31 Dec 2000 19:29:02 GMT
From: tohann@my-deja.com
Subject: Re: Retrieving HTML...
Message-Id: <92o1dp$iro$1@nnrp1.deja.com>

In article <t4q1mp2f06hlc7@corp.supernews.com>,
  Chris Stith <mischief@velma.motion.net> wrote:
> Mark Longhurst <nospam@bml.uk-mart.co.uk> wrote:
>
> > <tohann@my-deja.com> wrote in message
news:92iq13$rsh$1@nnrp1.deja.com...
> >> Ok, let me try to explain this another way then.  When you hit a
 .cgi
> >> program in a browser, the page is displayed.  Do a view source and
you
> >> see the HTML code.  That is what I want, the HTML code for the
page.  I
> >> don't know if CGI.pm or the LWP library have anything of use.  Is
this
> >> even possible in Perl?
> >>
>
> > Maybe I'm misunderstanding you, but it seems to me that you have
answered
> > your own question here.
>
> > As you say, all you need to do is execute the .cgi script, go to
view source
> > on the resulting page, and you've GOT the HTML source of the page.
Since
> > this is displayed in Notepad (under Win.) or I presume some other
text
> > editor under other O/S all you need to do then is save it with a
 .htm file
> > extension, and you're there.
>
> I'm thinking he wants to programmatically do the same sort of thing.
> What he needs to do is to grab the URL of the CGI with the proper
> parameters and process the page sent back. LWP or any other solution
> for grabbing a web page as a client should be able to do this if they
> have any support for CGI.
>
> Chris
>
> --
> Christopher E. Stith
>
> Even in the worst of times, there is always someone who's never had it
better.
> Even in the best of times, there is always someone who's never had it
worse.
>
>


Yes, Chris, that is what I'm talking about.  And thank you all for your
replies so far.  What I need to do is go through about 350+ .cgi
programs and capture the HTML source code.  As you said this can be done
by doing a view source on every page, but that could take me well into
the next millenium.  I tried using the LWP (::Simple get and getprint),
and it worked fine except for one thing.  I tested it on www.yahoo.com
and saw the source as I needed.  But then I tried using it for my
purpose and I got an error 501, Protocol scheme 'https' not supported.
And that's the only difference between my sites and yahoo.  Is there
some sort of work around for https sites?

Thanks in advance,
Trent



Sent via Deja.com
http://www.deja.com/


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

Date: Sun, 31 Dec 2000 19:58:32 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: Retrieving HTML...
Message-Id: <92o355$k40$1@nnrp1.deja.com>

In article <92o1dp$iro$1@nnrp1.deja.com>,
  tohann@my-deja.com wrote:
> In article <t4q1mp2f06hlc7@corp.supernews.com>,
>   Chris Stith <mischief@velma.motion.net> wrote:
> > Mark Longhurst <nospam@bml.uk-mart.co.uk> wrote:
> >
> > > <tohann@my-deja.com> wrote in message
> news:92iq13$rsh$1@nnrp1.deja.com...
> > >> Ok, let me try to explain this another way then.  When you hit a
> .cgi
> > >> program in a browser, the page is displayed.  Do a view source
and
> you
> > >> see the HTML code.

<big snip>

Not sure if this will help you Trent, but I have used this with much
success in the past...

#### start sub ####
use IO::Socket;

my ($document,$server,$remote);

$document = "http://somedomain.com/cgi-bin/program.cgi";
$server = "somedomain.com";

# open the socket
$remote = IO::Socket::INET->new(
	Proto=>"tcp",
	LocalPort=>1234,
	PeerAddr=>$server,
	PeerPort=>80,
	Reuse=>1) || die "Can't open socket\n";

# set buffering off
$remote->autoflush(1);

# open file to print captured results to
open (FILE,">users/$filename.txt");

print $remote "GET $document HTTP/1.0\n\n";

while(<$remote>) {
 print FILE;
 }

#close the socket
close $remote;
close(FILE);
#### end sub ####

This routine puts whatever you need into a file for further parsing. To
access https protocol you will have to slightly edit the protocol and
port variables.

Mark


--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 01 Jan 2001 01:11:13 -0700
From: "Doran Barton" <fozz@iodynamics.com>
Subject: Re: Retrieving HTML...
Message-Id: <92pduh$cht$1@news.xmission.com>

In article <92o1dp$iro$1@nnrp1.deja.com>, tohann@my-deja.com wrote:

> Yes, Chris, that is what I'm talking about.  And thank you all for your
> replies so far.  What I need to do is go through about 350+ .cgi
> programs and capture the HTML source code.  As you said this can be done
> by doing a view source on every page, but that could take me well into
> the next millenium.  I tried using the LWP (::Simple get and getprint),
> and it worked fine except for one thing.  I tested it on www.yahoo.com
> and saw the source as I needed.  But then I tried using it for my
> purpose and I got an error 501, Protocol scheme 'https' not supported.
> And that's the only difference between my sites and yahoo.  Is there
> some sort of work around for https sites?

Hate to pull a RTFM, but... 

From the README.SSL file distributed with libwww-perl:

SSL SUPPORT
-----------

The libwww-perl package has support for using SSL/TLSv1 with its HTTP
client and server classes. This support makes it possible to access
https schemed URLs with LWP. Because of the problematic status of
encryption software in general and certain encryption algorithms in
particular, in several countries, libwww-perl package doesn't include
SSL functionality out-of-the-box.

Encryption support is obtained through the use of Crypt::SSLeay or
IO::Socket::SSL, which can both be found from CPAN. While libwww-perl
has "plug-and-play" support for both of these modules (as of v5.45),
the recommended module to use is Crypt::SSLeay. In addition to
bringing SSL support to the LWP package, IO::Socket::SSL can be used
as an object oriented interface to SSL encrypted network sockets.

There is yet another SSL interface for perl called Net::SSLeay. It has
a more complete SSL interface and can be used for web client
programming among other things but doesn't directly support LWP.

The underlying SSL support in all of these modules is based on OpenSSL
<http://www.openssl.org/> (formerly SSLeay). For WWW-server side SSL
support (e.g. CGI/FCGI scripts) in Apache see <http://www.modssl.org/>.

----end-of-README.SSL

So... assuming you install the Crypt::SSLeay module, LWP::Simple will
automatically use it and you will be able to use LWP::Simple to retrieve
content from "secure" web servers.

-=Fozz

-- 
------------------------------------------------------------------------------
fozz@iodynamics.com -- Doran L. Barton - Chief Super Hero, Iodynamics LLC
    "A good messenger expects to get shot." -- Larry Wall


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

Date: Wed, 03 Jan 2001 14:44:50 GMT
From: hedley_s@my-deja.com
Subject: rsh/cvs problem
Message-Id: <92vdt1$3be$1@nnrp1.deja.com>

hi,

I'm just looking for hints or tips not a code solution.  Basically
I have a perl script that has automated some cvs tasks for me.

I would now like to be able to rsh to a remote machine and execute
some commands from within my script.  For example, I would firstly
like to log into the machine, cd to a directory and then execute a
command.

Does anyone know of a way this can be done in perl that would allow
me to check return codes etc.

thanks for any help

H


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 03 Jan 2001 14:58:13 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: rsh/cvs problem
Message-Id: <3a543dbf.2730614@news.tcn.net>

On Wed, 03 Jan 2001 14:44:50 GMT, hedley_s@my-deja.com wrote:

>I would now like to be able to rsh to a remote machine and execute
>some commands from within my script.  For example, I would firstly
>like to log into the machine, cd to a directory and then execute a
>command.
>
>Does anyone know of a way this can be done in perl that would allow
>me to check return codes etc.

What your trying to do sounds a touch complicated for rsh, you might
want to look into Expect.pm.

--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Wed, 03 Jan 2001 07:20:50 -0800
From: Zach Lipton <zach@zachlipton.com>
Subject: Re: rsh/cvs problem
Message-Id: <B6788352.2F60%zach@zachlipton.com>

in article 3a543dbf.2730614@news.tcn.net, Richard Zilavec at
rzilavec@tcn.net wrote on 1/3/01 6:58 AM:

> On Wed, 03 Jan 2001 14:44:50 GMT, hedley_s@my-deja.com wrote:
> 
>> I would now like to be able to rsh to a remote machine and execute
>> some commands from within my script.  For example, I would firstly
>> like to log into the machine, cd to a directory and then execute a
>> command.
>> 
>> Does anyone know of a way this can be done in perl that would allow
>> me to check return codes etc.
> 
> What your trying to do sounds a touch complicated for rsh, you might
> want to look into Expect.pm.
> 
> --
> Richard Zilavec
> rzilavec@tcn.net
For CVS the VCS::CVS module might help you along with the base VCS module.

Hope this helps

Zach



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

Date: Wed, 03 Jan 2001 16:48:16 GMT
From: hedley_s@my-deja.com
Subject: Re: rsh/cvs problem
Message-Id: <92vl4e$a1n$1@nnrp1.deja.com>

Thanks for your help guys.

> For CVS the VCS::CVS module might help you along with the base VCS
module.
>
> Hope this helps
>
> Zach
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: Thu, 04 Jan 2001 06:54:00 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: rsh/cvs problem
Message-Id: <c6V46.647$B9.191675904@news.frii.net>

In article <92vdt1$3be$1@nnrp1.deja.com>,  <hedley_s@my-deja.com> wrote:
>hi,
>
>I'm just looking for hints or tips not a code solution.  Basically
>I have a perl script that has automated some cvs tasks for me.
>
>I would now like to be able to rsh to a remote machine and execute
>some commands from within my script.  For example, I would firstly
>like to log into the machine, cd to a directory and then execute a
>command.
>
>Does anyone know of a way this can be done in perl that would allow
>me to check return codes etc.
>
>thanks for any help
>

there is usually no reason to resort to driving a command line
remotely.  the notable exception being some kinds of legacy equipment.

a more robust solution would be to wrap your commands in a script
being careful to include proper error checking. then install it on
the remote machine.  you can run it remotely using rsh, a webserver,
or a really long piece of dental floss.
-- 
    This space intentionally left blank


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

Date: Thu, 04 Jan 2001 14:33:19 GMT
From: hedley_s@my-deja.com
Subject: Re: rsh/cvs problem
Message-Id: <9321jf$9o2$1@nnrp1.deja.com>

In article <c6V46.647$B9.191675904@news.frii.net>,
  cfedde@fedde.littleton.co.us (Chris Fedde) wrote:

> there is usually no reason to resort to driving a command line
> remotely.  the notable exception being some kinds of legacy equipment.
>
> a more robust solution would be to wrap your commands in a script
> being careful to include proper error checking. then install it on
> the remote machine.  you can run it remotely using rsh, a webserver,
> or a really long piece of dental floss.
> --
>     This space intentionally left blank
>

Thanks for your input, I had the same idea initially, although found
that trying to manipulate was too cumbersome and didn't work properly.
I couldn't get cvs commands to work etc.

thanks

Hedley


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 1 Jan 2001 19:49:17 +1000
From: dolphin@localhost.localdomain (dolphin)
Subject: Script to disconnect users on a dialup system
Message-Id: <slrn950kkl.1t3.dolphin@localhost.localdomain>

== Script to disconnect users on a dialup system ==

I am searching fo a script that will do the following or something similar
but have looked to no avail. The script MUST be Perl on Linux.

1. Allow all dialup users to connect to a system for eight hours per day
maximum.

2. If any users have been connected for more than three hours and if there
is only one modem left unallocated in the pool then kick the longest user
off the system and allow the current dialin to connect to the system as
long as they:

 - have allocated hours remaining for the day
 - have not been kicked off in the past 30 minutes

3. Any user kicked off must wait 30 minutes before becoming eligible for a
reconnection, at which time they may use their remaining hours (up to five
hours maximum)

4. At midnight the users' allocations return to eight hours BUT any user
still on the system has when it rolls over midnight gets the extra time
deducted from the current day's allocation.

5. The script runs every 15 minutes via a cron job.

6. Other nice features??



























Yep, this is not a strict Perl question and I have not provided code
because I cannot find any and do not want to reinvent the wheel. So what!
This is the "misc" group!


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

Date: Tue, 02 Jan 2001 01:38:40 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Script to disconnect users on a dialup system
Message-Id: <Aia46.570$B9.190395392@news.frii.net>

In article <slrn950kkl.1t3.dolphin@localhost.localdomain>,
dolphin <dolphin@gargoyle.apana.org.au> wrote:
>== Script to disconnect users on a dialup system ==
>
>I am searching fo a script that will do the following or something similar
>but have looked to no avail. The script MUST be Perl on Linux.
>

[6 feature descriptions deleted]

This is a pretty detailed specification for a question to a usenet
news group.  I expect that there are connection auditing features
available in Linux that could be leveraged.    In any case it is
unlikely that a complete solution exists for this specific set of
features.

chris
-- 
    This space intentionally left blank


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 5246
**************************************


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