[24315] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6506 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 2 21:10:40 2004

Date: Sun, 2 May 2004 18:10:09 -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           Sun, 2 May 2004     Volume: 10 Number: 6506

Today's topics:
    Re: How to call another program <trammell+usenet@hypersloth.invalid>
    Re: How to call another program <1usa@llenroc.ude>
    Re: How to call another program <1usa@llenroc.ude>
    Re: How to call another program <flavell@ph.gla.ac.uk>
    Re: How to call another program <trammell+usenet@hypersloth.invalid>
    Re: How to call another program <1usa@llenroc.ude>
    Re: How to call another program <David@Grey.con>
    Re: How to call another program <jtc@shell.dimensional.com>
    Re: How to call another program <David@Grey.con>
    Re: How to call another program <tony_curtis32@_SPAMTRAP_yahoo.com>
    Re: How to call another program <uri@stemsystems.com>
    Re: How to call another program <David@Grey.con>
    Re: How to call another program <David@Grey.con>
    Re: How to call another program <David@Grey.con>
    Re: How to call another program <1usa@llenroc.ude>
    Re: How to call another program <matternc@comcast.net>
    Re: How to call another program <1usa@llenroc.ude>
    Re: How to call another program <David@Grey.con>
    Re: How to call another program (Sam Holden)
    Re: Longest match wins - how to do it Perl way? <No_4@dsl.pipex.com>
    Re: MSSQL 2000 Connect Success <***************>
    Re: need help with security <gnari@simnet.is>
    Re: need help with security <mark.clements@kcl.ac.uk>
    Re: OSs with Perl installed <abigail@abigail.nl>
    Re: Regexp question... <gnari@simnet.is>
    Re: Regexp question... <noreply@gunnar.cc>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 2 May 2004 22:02:25 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: How to call another program
Message-Id: <slrnc9arvh.74n.trammell+usenet@hypersloth.el-swifto.com.invalid>

On Sun, 02 May 2004 21:35:53 GMT, David Grey <David@Grey.con> wrote:
> Tony Curtis wrote:
>> No, you want to GET (I assume) the URL above, and process the
>> response in some way.
>
> No, I just want it to run, period, then the rest of the script that
> calls that script to run, that's it.
>
>> perldoc lwpcook, it has examples of building requests and
>> handling the responses.
> 
> But it had nothing that shows how to run a script. I
> do not want to copy a file, I want to run the script, then
> finish the process.
> 
>> LWP::Simple may be enough for what you're trying to do, but
>> it's difficult to tell.
>>
>> To repeat: you are *not* running a script on another machine,
>> you are accessing a URL and processing its response.
> 
> There goes that german again. Care to give an example that (I don't
> even know what to call it because you say I can't use the word run so
> I call it dlksj) I want to dlksj the script on the domain.com and
> continue the process. Nothing more, nothing less.
> 
>> That might be what is going on "under the hood" but it is
>> irrelevant.  You really need to understand the difference between
>> running programs and processing URL responses, I have the feeling
>> this is tripping you up unnecessarily.
> 
> I want to dlksj the script and continue on.
> 
> print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
> 
> does it but never comes back.
> 

OK, I'll bite.

When you dlksj a script, what's happening?  You're using a web browser
of some sort to request a file from a web server.  The server realizes
that it isn't a .gif or an .html file, but a script, so it runs the
script, and the output is returned to you and displayed by your browser.

The trick is that that script can, in turn, act like its own little web
browser.  The tools to have it do that are in Perl's LWP (libwww-perl).

Here's a script that retreives the front pages from Yahoo! and Google,
and prints the output:

  #!/usr/bin/perl
  use strict;
  use warnings;
  use LWP::Simple;
  my $yahoo = get("http://www.yahoo.com/");
  my $google = get("http://www.google.com/");
  print $yahoo, $google;

That's how you can dlksj your script that's on some other server, but
not have your browser get stuck there.



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

Date: 2 May 2004 22:12:40 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: How to call another program
Message-Id: <Xns94DDB941BF987asu1cornelledu@132.236.56.8>

David Grey <David@Grey.con> wrote in news:4095655B.DC69082E@Grey.con:

> A. Sinan Inner wrote:

This string is normally inserted by your newsreader. Why did you change my 
last name?

>> I just showed you another way. Did you actually try that script out
>> with the URL you are interested in?

> I'm not going to try what will not do what I want, I want
> to run a script in a script, I saw no evidence what you posted
> would do that.

http://www.ext.nodak.edu/extpubs/alt-ag/ostrich.htm

> Oh please, you can't know about something before you know about
> something, you just want to flame others, not help them.

No, I do not. But I don't like it when Tony posts a nice explanation and 
you call it 'gibberish'.

> I don't see why you are here other than to gloat I know more than
> you idiots.

Nice.

> You cannot look up what you have no clue what to
> look up, and you cannot learn something that is not in your
> existence yet.

How do you find the courage to leave home everyday?

> I have done my work, I just need a clue how to run a 
> script in a script, not get a file as it seems you posted.

HTTP does not work that way. What you have is a resource on another web 
server. Requesting that resource results in a Perl CGI script being 
executed on that server. When you do a redirect, you take your script out 
of the picture. Kind of like setting up a blind date as opposed to going on 
a double date.

If you are not interested in the actual content of the resource on the 
other server, then you should be able to get away with using the head 
function in LWP::Simple rather than get.

> I need to run a script at domain.com in a script, period.

No you don't.

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: 2 May 2004 22:16:47 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: How to call another program
Message-Id: <Xns94DDB9F41C8CDasu1cornelledu@132.236.56.8>

"John J. Trammell" <trammell+usenet@hypersloth.invalid> wrote in 
news:slrnc9arvh.74n.trammell+usenet@hypersloth.el-swifto.com.invalid:

> The trick is that that script can, in turn, act like its own little web
> browser.  The tools to have it do that are in Perl's LWP (libwww-perl).
> 
> Here's a script that retreives the front pages from Yahoo! and Google,
> and prints the output:
> 
>   #!/usr/bin/perl
>   use strict;
>   use warnings;
>   use LWP::Simple;
>   my $yahoo = get("http://www.yahoo.com/");
>   my $google = get("http://www.google.com/");
>   print $yahoo, $google;
> 
> That's how you can dlksj your script that's on some other server, but
> not have your browser get stuck there.

Please don't do that.

[Sun May 02 18:15:47 2004] [error] [client 127.0.0.1] malformed header from 
script. Bad header=<html><head>: t5.pl


-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Sun, 2 May 2004 23:15:23 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: How to call another program
Message-Id: <Pine.LNX.4.53.0405022257420.8123@ppepc56.ph.gla.ac.uk>

On Sun, 2 May 2004, David Grey wrote:

(in reply to A. Sinan Unur , and your carelessness with attributions
isn't helping your case:]

> I'm not going to try what will not do what I want, I want
> to run a script in a script, I saw no evidence what you posted
> would do that.

Actually that's not as obvious as it seems.  You obviously don't yet
understand what you are doing nor how to properly ask about what you
want - which is perfectly OK - we all have to start somewhere; it
would be to your advantage to explore all kinds of relevant building
blocks so that you could get a better feel for how they fit together,
after which, the answer to your problem will likely seem so obvious
that you won't need to ask about it.

> Oh please, you can't know about something before you know about
> something, you just want to flame others, not help them.
> I don't see why you are here other than to gloat I know more than
> you idiots.

You don't seem to have the remotest clue what kind of impression
you're making by this kind of public exhibition.  As such, my own
interim reaction is that you probably can't be helped.  But I'll give
you the benefit of the doubt before you go into the killfile, and the
answer might just be helpful to someone else.

> I just need a clue how to run a script in a script, not get a file
> as it seems you posted.

Not on the basis of your own evidence, no.  You want to invoke a
remote URL which happens to have a script behind it, while retaining
control of the situation so that you can return the result.  The
answer to that is LWP.

> I need to run a script at domain.com in a script, period.

You don't know how to ask the question yet; that's OK - we all have to
make a start somewhere - but I'd say, on the basis of the most
plausible interpretation of what you want, is that the answer is LWP.


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

Date: Sun, 2 May 2004 22:31:02 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: How to call another program
Message-Id: <slrnc9atl6.92a.trammell+usenet@hypersloth.el-swifto.com.invalid>

On 2 May 2004 22:16:47 GMT, A. Sinan Unur <1usa@llenroc.ude> wrote:
> Please don't do that.

Do what?

> [Sun May 02 18:15:47 2004] [error] [client 127.0.0.1] malformed header
> from script. Bad header=<html><head>: t5.pl

I never said it was a CGI script.



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

Date: 2 May 2004 22:38:23 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: How to call another program
Message-Id: <Xns94DDBD9D56BAFasu1cornelledu@132.236.56.8>

"John J. Trammell" <trammell+usenet@hypersloth.invalid> wrote in 
news:slrnc9atl6.92a.trammell+usenet@hypersloth.el-swifto.com.invalid:

> On 2 May 2004 22:16:47 GMT, A. Sinan Unur <1usa@llenroc.ude> wrote:
>> Please don't do that.
> 
> Do what?
> 
>> [Sun May 02 18:15:47 2004] [error] [client 127.0.0.1] malformed header
>> from script. Bad header=<html><head>: t5.pl
> 
> I never said it was a CGI script.

Which I assumed because of the context of the OP's request. My bad.

Sinan.


-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Sun, 02 May 2004 22:59:06 GMT
From: David Grey <David@Grey.con>
Subject: Re: How to call another program
Message-Id: <409576A7.EB85D4F2@Grey.con>



John J. Trammell wrote:

> On Sun, 02 May 2004 21:35:53 GMT, David Grey <David@Grey.con> wrote:
> > Tony Curtis wrote:
> >> No, you want to GET (I assume) the URL above, and process the
> >> response in some way.
> >
> > No, I just want it to run, period, then the rest of the script that
> > calls that script to run, that's it.
> >
> >> perldoc lwpcook, it has examples of building requests and
> >> handling the responses.
> >
> > But it had nothing that shows how to run a script. I
> > do not want to copy a file, I want to run the script, then
> > finish the process.
> >
> >> LWP::Simple may be enough for what you're trying to do, but
> >> it's difficult to tell.
> >>
> >> To repeat: you are *not* running a script on another machine,
> >> you are accessing a URL and processing its response.
> >
> > There goes that german again. Care to give an example that (I don't
> > even know what to call it because you say I can't use the word run so
> > I call it dlksj) I want to dlksj the script on the domain.com and
> > continue the process. Nothing more, nothing less.
> >
> >> That might be what is going on "under the hood" but it is
> >> irrelevant.  You really need to understand the difference between
> >> running programs and processing URL responses, I have the feeling
> >> this is tripping you up unnecessarily.
> >
> > I want to dlksj the script and continue on.
> >
> > print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
> >
> > does it but never comes back.
> >
>
> OK, I'll bite.
>
> When you dlksj a script, what's happening?

One of two things, if I put in:

print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";

it go on its merry way and runs the script on domain.com and
the rest of the script is ignored, if I take it out it  runs only
the script, I'm fickled and want it to do both. Run both
scripts, the one on domain.com first and wait until it is done.
Is that not forking() ? And everyone is now saying no it is not
forking.



> You're using a web browser
> of some sort to request a file from a web server.

Not that I know of, I put in the URL to the script and it
does whatever voo doo it do.


>  The server realizes
> that it isn't a .gif or an .html file, but a script, so it runs the
> script, and the output is returned to you and displayed by your browser.

Only if there is an error. It is all supposed to be done behind the
scene, they click on a URL and it runs both scripts (well that is
what I want).

>
>
> The trick is that that script can, in turn, act like its own little web
> browser.  The tools to have it do that are in Perl's LWP (libwww-perl).

Yeah I have that in there to get a file after the script I want
to run, runs. But that is in the continued part, I just need to
run the script on the domain.com first. (That part is working
fine, but it is not running the scritpt that makes the file in the
first place.)

>
>
> Here's a script that retreives the front pages from Yahoo! and Google,
> and prints the output:
>
>   #!/usr/bin/perl
>   use strict;
>   use warnings;
>   use LWP::Simple;
>   my $yahoo = get("http://www.yahoo.com/");
>   my $google = get("http://www.google.com/");
>   print $yahoo, $google;
>
> That's how you can dlksj your script that's on some other server, but
> not have your browser get stuck there.



Yeah, but that is not running a script on google. I got this
part, I need to run (dlksj) a script.

I thank you, very much anyway.





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

Date: 2 May 2004 17:09:47 -0600
From: Jim Cochrane <jtc@shell.dimensional.com>
Subject: Re: How to call another program
Message-Id: <slrnc9avtr.i34.jtc@shell.dimensional.com>

In article <Xns94DDB941BF987asu1cornelledu@132.236.56.8>, A. Sinan Unur wrote:
> David Grey <David@Grey.con> wrote in news:4095655B.DC69082E@Grey.con:
> 
>> A. Sinan Inner wrote:
> 
> This string is normally inserted by your newsreader. Why did you change my 
> last name?
> 
>>> I just showed you another way. Did you actually try that script out
>>> with the URL you are interested in?
> 
>> I'm not going to try what will not do what I want, I want
>> to run a script in a script, I saw no evidence what you posted
>> would do that.
> 
> http://www.ext.nodak.edu/extpubs/alt-ag/ostrich.htm
> 
>> Oh please, you can't know about something before you know about
>> something, you just want to flame others, not help them.
> 
> No, I do not. But I don't like it when Tony posts a nice explanation and 
> you call it 'gibberish'.
> 
>> I don't see why you are here other than to gloat I know more than
>> you idiots.
> 
> Nice.
> 
>> You cannot look up what you have no clue what to
>> look up, and you cannot learn something that is not in your
>> existence yet.

People posting to this group for help (and, for that matter, to almost all
technical groups) need to realize that they are asking for free consulting
services.  (Answering a, possibily difficult, programming-related question
is consulting.)  Like many groups, there are knowledgeable people willing
to provide those services; but those asking for help should keep in mind
that the service is being provided, out of generosity, for no charge, and
that some patience and willingness to do one's own homework is often
required in order to benefit from these services.  Sometimes it can seem
that people are being abusive (and sometimes that is actually the case),
but if one realizes that people are providing these services for free, one
may be more willing to not take the percieved abuse personally and will
more likely benefit from the resulting interaction.

And remember, there is no contract in this forum - If you don't get your
question answered, you are not justified in complaining to the BBB (or
whereerver).  But if you have patience and appreciate the generosity of
those who respond to your question, you are more likely to obtain a
satisfactory result in the end.

-- 
Jim Cochrane; jtc@dimensional.com
[When responding by email, include the term non-spam in the subject line to
get through my spam filter.]


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

Date: Sun, 02 May 2004 23:10:36 GMT
From: David Grey <David@Grey.con>
Subject: Re: How to call another program
Message-Id: <4095795A.EBD9E03C@Grey.con>



Tony Curtis wrote:

> >> On Sun, 02 May 2004 21:45:16 GMT,
> >> David Grey <David@Grey.con> said:
>
> > no clue what to look up, and you cannot learn something that
> > is not in your existence yet. I have done my work, I just
> > need a clue how to run a script in a script,
>
> You are *not* running a "script in a script".
>
> > not get a file as it seems you posted.  I need to run a
> > script at domain.com in a script, period.
>
> No, you want to process the response from accessing a URL via
> some kind of HTTP request, probably GET.
>
> This is your stumbling block.  You are conflating accessing a
> URL with the particular language in which you happened to code
> the underlying implementation of that URL.
>
> Or not in German, you want to connect to a webserver and
> access something on that server.  (The something happens to be
> implemented as a perl program.  That program outputs
> something.)

I actually understood that part, :-) I don't need the output,
because the output is a file that is made on domain.com
It is called later and I have that worked out, I just need to
(I guess as you said GET it) but then I need to make sure
it finishes making the file before continuing, is that not
forking()?


> You want to collect what was output and then do
> something else.


Not directly, not at that point, I just want to (your  german)
"process the response from accessing a URL via some kind
of HTTP request" but it needs to wait like 10 seconds to
make sure it has made the file before continuing the script.


thanks





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

Date: Sun, 02 May 2004 18:16:05 -0500
From: Tony Curtis <tony_curtis32@_SPAMTRAP_yahoo.com>
Subject: Re: How to call another program
Message-Id: <873c6il8sq.fsf@limey.hpcc.uh.edu>

>> On Sun, 02 May 2004 23:10:36 GMT,
>> David Grey <David@Grey.con> said:

> I actually understood that part, :-) I don't need the

Leiwand!

> output, because the output is a file that is made on
> domain.com It is called later and I have that worked out, I
> just need to (I guess as you said GET it) but then I need to
> make sure it finishes making the file before continuing, is
> that not forking()?

It is quasi-analogous to forking.  Doing a redirect is
quasi-analogous to an exec().  But different to the point that
it isn't really helpful to pursue the analogy.

> Not directly, not at that point, I just want to (your
> german) "process the response from accessing a URL via some
> kind of HTTP request" but it needs to wait like 10 seconds
> to make sure it has made the file before continuing the
> script.

So it's asynchronous at the remote end and you have no
callback or notification method?  All bets are off.

If you really don't care what comes back from the request,
just do a "get" from LWP::Simple and discard the result.  Make
sure the request worked though, and handle failure gracefully.
(Put in a sleep if that's the only way to ensure no race
hazards.)



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

Date: Sun, 02 May 2004 23:19:08 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to call another program
Message-Id: <x7wu3uwh78.fsf@mail.sysarch.com>


wow. all i can say is wow. what more do we need to do to get you to
understand what is happening and why your understanding of it is so
skewed.

let me try. i need a good challenge.

ok, when you request web page (be it a file or dynamic like a cgi) you
make a connection to that web server and it does the work for you. you
don't care about what script it runs so calling it that like you do is
wrong. all you can do is fetch a page (we are ignoring file loads for
now).

ok, you can fetch a page by a browser or by any program that acts and
looks like a browser. these programs are called user agents and perl's
version is in a library called LWP.

and finally, a redirection does not RUN ANYTHING. it simply tells the
browser to IGNORE the rest of this page (which is why you never get
anything else from it) and load the page to which it redirects. so you
are not running or fetching ANYTHING in your existing script. you are
telling the BROWSER to fetch something else.

so now let's put this all together. redirect as you are doing will NEVER
work as its function is to cause the browser to go to somewhere
else. you lost control of the situation as soon as the browser is told
to redirect. so you need some way to fetch a page (NOT RUN A
SCRIPT. that is WRONG THINKING) from inside your cgi so YOU CAN KEEP
CONTROL of the situation. the key is CONTROL but you lose that with a
redirection.

so inside your cgi script you RUN AN LWP command like you have seen
several times in this thread. YOU GET the results in YOUR script and not
in the browser. BUT WATCH! YOU can send those results TO THE BROWSER
yourself with a print call. and THEN YOU KEEP CONTROL!!! wowie!!!
staying in control is the name of the game! now that you have control,
you just run the rest of your script and feel very happy.

and when 10 people tell you that you aren't running a script when you do
a redirection, try listening to them. you have showns a severe lacking
in the basics of how the web works. find a decent tutorial and learn
about it before you write code that interacts with it.

i hope this helps. if it doesn't, either you have no sense of humor or
else no senses whatsoever and should leave the programming to pros.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sun, 02 May 2004 23:21:55 GMT
From: David Grey <David@Grey.con>
Subject: Re: How to call another program
Message-Id: <40957BFF.B90A1138@Grey.con>



A. Sinan Unur wrote:

> David Grey <David@Grey.con> wrote in news:4095655B.DC69082E@Grey.con:
>
> > A. Sinan Inner wrote:
>
> This string is normally inserted by your newsreader. Why did you change my
> last name?

I did not, unless it was by accident. I have big fingers and a
little lap top.

>
>
> >> I just showed you another way. Did you actually try that script out
> >> with the URL you are interested in?
>
> > I'm not going to try what will not do what I want, I want
> > to run a script in a script, I saw no evidence what you posted
> > would do that.
>
> http://www.ext.nodak.edu/extpubs/alt-ag/ostrich.htm
>
> > Oh please, you can't know about something before you know about
> > something, you just want to flame others, not help them.
>
> No, I do not. But I don't like it when Tony posts a nice explanation and
> you call it 'gibberish'.

If I don't understand it, it is gibberish, if my ignorance offends
you pluck something out.


>
>
> > I don't see why you are here other than to gloat I know more than
> > you idiots.
>
> Nice.
>
> > You cannot look up what you have no clue what to
> > look up, and you cannot learn something that is not in your
> > existence yet.
>
> How do you find the courage to leave home everyday?
>
> > I have done my work, I just need a clue how to run a
> > script in a script, not get a file as it seems you posted.
>
> HTTP does not work that way. What you have is a resource on another web
> server. Requesting that resource results in a Perl CGI script being
> executed on that server. When you do a redirect, you take your script out
> of the picture. Kind of like setting up a blind date as opposed to going on
> a double date.
>
> If you are not interested in the actual content of the resource on the
> other server, then you should be able to get away with using the head
> function in LWP::Simple rather than get.

Damn that had to hurt, you were actually constructive there :-)

And on top of that I understood what you said.

>
>
> > I need to run a script at domain.com in a script, period.
>
> No you don't.

I know you are, but what am I.


Thanks





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

Date: Mon, 03 May 2004 00:36:21 GMT
From: David Grey <David@Grey.con>
Subject: Re: How to call another program
Message-Id: <40958D69.C15ECCAF@Grey.con>



Tony Curtis wrote:

> >> On Sun, 02 May 2004 23:10:36 GMT,
> >> David Grey <David@Grey.con> said:
>
> > I actually understood that part, :-) I don't need the
>
> Leiwand!

Sie sind nett gewesen

>
>
> > output, because the output is a file that is made on
> > domain.com It is called later and I have that worked out, I
> > just need to (I guess as you said GET it) but then I need to
> > make sure it finishes making the file before continuing, is
> > that not forking()?
>
> It is quasi-analogous to forking.  Doing a redirect is
> quasi-analogous to an exec().  But different to the point that
> it isn't really helpful to pursue the analogy.
>
> > Not directly, not at that point, I just want to (your
> > german) "process the response from accessing a URL via some
> > kind of HTTP request" but it needs to wait like 10 seconds
> > to make sure it has made the file before continuing the
> > script.
>
> So it's asynchronous at the remote end and you have no
> callback or notification method?  All bets are off.

Yeah that's about the size of it, I guess.

>
>
> If you really don't care what comes back from the request,
> just do a "get" from LWP::Simple and discard the result.  Make
> sure the request worked though, and handle failure gracefully.
> (Put in a sleep if that's the only way to ensure no race
> hazards.)


I tried:

sleep 10

and it gave me an 500 error, I took it out and no errors and
no success. Does "sleep 10" need a "use" file  or is this the
wrong useage? This is what I have:

#!/usr/bin/perl

use warnings;
use strict;

use LWP::UserAgent;
use URI;

$ua = new LWP::UserAgent;
$uri = new URI('http://www.domain.com/temp.txt');
$localfile = 'temp.txt';

# This part just added .. start --------
$ua2 = new LWP::UserAgent;
$uri2 = new URI('http://www.domain.com/copyprog.pl');

my $request = HTTP::Request->new('GET', $uri2);
my $result = $ua2->request($request);
# sleep 10
# end .. of new part ----------

# Create request with HTTP 1.1-style Range header
my $request = HTTP::Request->new('GET', $uri);

# Fetch it
my $result = $ua->request($request);

# Append the fetched data to the local file
open OUT,">>$localfile";
print OUT $result->content;
close OUT;





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

Date: Mon, 03 May 2004 00:48:14 GMT
From: David Grey <David@Grey.con>
Subject: Re: How to call another program
Message-Id: <40959030.9AF7DA85@Grey.con>



Jim Cochrane wrote:

> In article <Xns94DDB941BF987asu1cornelledu@132.236.56.8>, A. Sinan Unur wrote:
> > David Grey <David@Grey.con> wrote in news:4095655B.DC69082E@Grey.con:
> >
> >> A. Sinan Inner wrote:
> >
> > This string is normally inserted by your newsreader. Why did you change my
> > last name?
> >
> >>> I just showed you another way. Did you actually try that script out
> >>> with the URL you are interested in?
> >
> >> I'm not going to try what will not do what I want, I want
> >> to run a script in a script, I saw no evidence what you posted
> >> would do that.
> >
> > http://www.ext.nodak.edu/extpubs/alt-ag/ostrich.htm
> >
> >> Oh please, you can't know about something before you know about
> >> something, you just want to flame others, not help them.
> >
> > No, I do not. But I don't like it when Tony posts a nice explanation and
> > you call it 'gibberish'.
> >
> >> I don't see why you are here other than to gloat I know more than
> >> you idiots.
> >
> > Nice.
> >
> >> You cannot look up what you have no clue what to
> >> look up, and you cannot learn something that is not in your
> >> existence yet.
>
> People posting to this group for help (and, for that matter, to almost all
> technical groups) need to realize that they are asking for free consulting
> services.  (Answering a, possibily difficult, programming-related question
> is consulting.)  Like many groups, there are knowledgeable people willing
> to provide those services; but those asking for help should keep in mind
> that the service is being provided, out of generosity, for no charge, and
> that some patience and willingness to do one's own homework is often
> required in order to benefit from these services.  Sometimes it can seem
> that people are being abusive (and sometimes that is actually the case),
> but if one realizes that people are providing these services for free, one
> may be more willing to not take the percieved abuse personally and will
> more likely benefit from the resulting interaction.
>
> And remember, there is no contract in this forum - If you don't get your
> question answered, you are not justified in complaining to the BBB (or
> whereerver).  But if you have patience and appreciate the generosity of
> those who respond to your question, you are more likely to obtain a
> satisfactory result in the end.

Well I agree with what you say, and I am a consultant at times,
but if I know the answer and I am in a group I know the information
is given freely and try to give a answer that is not of the form go
look it up for yourself (with an implied lazy sod, ignorant twit).
If I know how to solve the problem and I have a program I
can copy and past that will do it with a little modification, I just
give it. Programming  is mostly learned by doing it, but you have
to know how to do it in the first place, and that takes examples,
not use   Perldoc -f sample   whatever that is. If you don't know
what that is, it is no help. I don't have perl on my PC computer.






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

Date: 3 May 2004 00:49:32 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: How to call another program
Message-Id: <Xns94DDD3D9F767Aasu1cornelledu@132.236.56.8>

David Grey <David@Grey.con> wrote in news:40958D69.C15ECCAF@Grey.con:

> Tony Curtis wrote:

Please quote properly.

>> So it's asynchronous at the remote end and you have no
>> callback or notification method?  All bets are off.
> 
> Yeah that's about the size of it, I guess.
> 
>> If you really don't care what comes back from the request,
>> just do a "get" from LWP::Simple and discard the result.  Make
>> sure the request worked though, and handle failure gracefully.
>> (Put in a sleep if that's the only way to ensure no race
>> hazards.)
> 
> 
> I tried:
> 
> sleep 10
> 
> and it gave me an 500 error, I took it out and no errors and
> no success. Does "sleep 10" need a "use" file  or is this the
> wrong useage? This is what I have:
> 
> #!/usr/bin/perl
> 
> use warnings;
> use strict;
> 
> use LWP::UserAgent;
> use URI;
> 
> $ua = new LWP::UserAgent;
> $uri = new URI('http://www.domain.com/temp.txt');
> $localfile = 'temp.txt';
> 
> # This part just added .. start --------
> $ua2 = new LWP::UserAgent;
> $uri2 = new URI('http://www.domain.com/copyprog.pl');
> 
> my $request = HTTP::Request->new('GET', $uri2);
> my $result = $ua2->request($request);
> # sleep 10
> # end .. of new part ----------
> 
> # Create request with HTTP 1.1-style Range header
> my $request = HTTP::Request->new('GET', $uri);
> 
> # Fetch it
> my $result = $ua->request($request);
> 
> # Append the fetched data to the local file
> open OUT,">>$localfile";
> print OUT $result->content;
> close OUT;

Hmmmmm ...

C:\Home> perl -c t3
"my" variable $request masks earlier declaration in same scope at t3 line 
23.
"my" variable $result masks earlier declaration in same scope at t3 line 
26.
Global symbol "$ua" requires explicit package name at t3 line 9.
Global symbol "$uri" requires explicit package name at t3 line 10.
Global symbol "$localfile" requires explicit package name at t3 line 11.
Global symbol "$ua2" requires explicit package name at t3 line 14.
Global symbol "$uri2" requires explicit package name at t3 line 15.
Global symbol "$uri2" requires explicit package name at t3 line 17.
Global symbol "$ua2" requires explicit package name at t3 line 18.
Global symbol "$uri" requires explicit package name at t3 line 23.
Global symbol "$ua" requires explicit package name at t3 line 26.
Global symbol "$localfile" requires explicit package name at t3 line 29.
t3 had compilation errors.

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Sun, 02 May 2004 20:50:08 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: How to call another program
Message-Id: <y6GdnV6cV9jdCgjdRVn-uw@comcast.com>

David Grey wrote:

> 
> If I don't understand it, it is gibberish, 

An attitude that guarantees that you will never learn anything.
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: 3 May 2004 00:51:40 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: How to call another program
Message-Id: <Xns94DDD436BD582asu1cornelledu@132.236.56.8>

David Grey <David@Grey.con> wrote in news:40959030.9AF7DA85@Grey.con:

> If you don't know what that is, it is no help. I don't have perl 
> on my PC computer.

Why not? Seriously, it does not take much to install Apache and ActiveState 
Perl. That way, you can try things out much more easily.

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Mon, 03 May 2004 01:01:19 GMT
From: David Grey <David@Grey.con>
Subject: Re: How to call another program
Message-Id: <4095931A.A50A61C7@Grey.con>



Alan J. Flavell wrote:

> On Sun, 2 May 2004, David Grey wrote:
>
> (in reply to A. Sinan Unur , and your carelessness with attributions
> isn't helping your case:]
>
> > I'm not going to try what will not do what I want, I want
> > to run a script in a script, I saw no evidence what you posted
> > would do that.
>
> Actually that's not as obvious as it seems.  You obviously don't yet
> understand what you are doing nor how to properly ask about what you
> want - which is perfectly OK - we all have to start somewhere; it
> would be to your advantage to explore all kinds of relevant building
> blocks so that you could get a better feel for how they fit together,
> after which, the answer to your problem will likely seem so obvious
> that you won't need to ask about it.

Well I'm sure that is the case, but I am living in the real world
and need this done yesterday, I don't have time for theory
and a learning experience today, I need this fixed. And it is
a bit frustrating to get the answer, go look it up, when you know
they know the answer but wont tell you. (Not in a form that
comprehendable at my level of understanding.)

>
>
> > Oh please, you can't know about something before you know about
> > something, you just want to flame others, not help them.
> > I don't see why you are here other than to gloat I know more than
> > you idiots.
>
> You don't seem to have the remotest clue what kind of impression
> you're making by this kind of public exhibition.  As such, my own
> interim reaction is that you probably can't be helped.  But I'll give
> you the benefit of the doubt before you go into the killfile, and the
> answer might just be helpful to someone else.

Well by this time I figured all I was going to get was more
go look it up you lead filled brained retard and figured I had
nothing left to lose.

>
>
> > I just need a clue how to run a script in a script, not get a file
> > as it seems you posted.
>
> Not on the basis of your own evidence, no.  You want to invoke a
> remote URL which happens to have a script behind it, while retaining
> control of the situation so that you can return the result.  The
> answer to that is LWP.

I tried GET and HEAD and it did not work, do you have a
short example?

>
>
> > I need to run a script at domain.com in a script, period.
>
> You don't know how to ask the question yet; that's OK - we all have to
> make a start somewhere - but I'd say, on the basis of the most
> plausible interpretation of what you want, is that the answer is LWP.


It would be the best thing if so, I already know a bit about that,
but still have not got anything that worked. But not getting any
errors is welcomed as well.

Thanks







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

Date: 3 May 2004 01:03:47 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to call another program
Message-Id: <slrnc9b6jj.qof.sholden@flexal.cs.usyd.edu.au>

On Mon, 03 May 2004 00:48:14 GMT, David Grey <David@Grey.con> wrote:
> 
> 
> Jim Cochrane wrote:
> 
>> And remember, there is no contract in this forum - If you don't get your
>> question answered, you are not justified in complaining to the BBB (or
>> whereerver).  But if you have patience and appreciate the generosity of
>> those who respond to your question, you are more likely to obtain a
>> satisfactory result in the end.
> 
> Well I agree with what you say, and I am a consultant at times,
> but if I know the answer and I am in a group I know the information
> is given freely and try to give a answer that is not of the form go
> look it up for yourself (with an implied lazy sod, ignorant twit).

Whereas people who actually want others to learn things show them how
to find out. Give a man a fish, teach a man to fish, yada yada.

This is not a group working on a project, this is usenet you get
the answers you get. If you show just a hint of motivation to actually
learn something you get much better answers. If you don't you get 
ignored.

In fact some of the answers to the original post have been very
good indeed. Pointing out exactly the terminology/understanding
problems and providing complete answers to the problem.

> If I know how to solve the problem and I have a program I
> can copy and past that will do it with a little modification, I just
> give it. Programming  is mostly learned by doing it, but you have
> to know how to do it in the first place, and that takes examples,
> not use   Perldoc -f sample   whatever that is. If you don't know
> what that is, it is no help. I don't have perl on my PC computer.

Do we have to explain how to turn the computer on as well? Or
can we assume you can work that much out yourself.

If we don't then why do we have to explain how to read documentation
on your particular flavour of computer?

This is not a suitable forum for learning the basic first steps of
Perl programming. There are books for that. There are courses for that.
There are tutorials (or varying quality) on the web for that.

If you haven't heard of something that is mentioned (mind you a few pages
down) in the main perl documention (man perl - or for people who can't be
bothered looking up what man means,
Start menu->Programs->ActiveState Perl->Documentation or something
like that...) then you haven't bothered spending two minutes searching
yourself before deciding that your time is far more valuable than the
time of thousands of others who obviously have nothing better to do
then solve your problems for you.

-- 
Sam Holden


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

Date: Mon, 03 May 2004 01:45:35 +0100
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Longest match wins - how to do it Perl way?
Message-Id: <409595e8$0$25327$cc9e4d1f@news-text.dial.pipex.com>

A. Farber wrote:
> 
> # put the longest keys first, to make them win
> 
> my @KEYS = qw( p1881_aq_ p1881_ p1972_ p1981_ p2311_ );
> 
> my %MAIL = (p1881_aq_ => {name => 'Project Aqua',

    A bit of a maintenance problem?  Why not let Perl generate @KEYS?

  my @KEYS = sort { length($b) <=> length($a) } keys %MAIL;

>     for my $p (@selected_projects) { 
>         for my $k (@KEYS) {

     last if (length($k) < length(p));   # Useful if you have a lot

>             if (0 == index $p, $k) {

-- 
      -*-    Just because I've written it here doesn't    -*-
      -*-    mean that you should, or I do, believe it.   -*-



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

Date: Sun, 02 May 2004 19:40:52 -0500
From: Henry Williams <***************>
Subject: Re: MSSQL 2000 Connect Success
Message-Id: <725b901jh8kb9k6rvhmi8dg2aj5im79hqu@4ax.com>


>
>There is a Win32::ODBC because Dave Roth decided to write it.  Same deal 
>with DBI, DBD::ODBC and DBD::ADO, and the other 4000+ modules.  As to 
>why Dave decided to write Win32::ODBC, I can only speculate.  Perhaps he 
>liked Micro$loth's way of accessing databases?  Maybe it predated DBI 
>and DBD::ODBC?

Thank you for your reply Mr. Walton. It sheds some light on the
matter.
I'm sure an analysis of each would be interesting , however I'll be
sticking with WIN32::ODBC as it does seem to work well and I'm stuck
with MS SQL 2k

Regards,
Henry



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

Date: Mon, 3 May 2004 00:15:43 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: need help with security
Message-Id: <c742sf$6gh$1@news.simnet.is>

"Robin" <webmaster @ infusedlight . net> wrote in message
news:c73lo9$a08$1@reader2.nmix.net...
> Someone posted an unathorized post to my blog, if someone has time...could
> you check this out, http://www.infusedlight.net/robin/temp/blog.txt and
> point out the security problems??
>

of course, it is your auth.pl that is the weakest link.

gnari






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

Date: Mon, 03 May 2004 02:04:07 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: need help with security
Message-Id: <40959a87$1@news.kcl.ac.uk>

Robin wrote:
> Someone posted an unathorized post to my blog, if someone has time...could
> you check this out, http://www.infusedlight.net/robin/temp/blog.txt and
> point out the security problems??
quick read (can't be arsed to consider the security problems):

my $rootfile =
$rootfile =~ s/.+\///;

what is this supposed to be doing?

my @blogposts;
@blogposts = getposts ();

why is this two lines?

perltidy is still your friend. Please use it.

     $mon++;
     $year +=1900;

why are you doing this? There are many fine CPAN modules that handles 
dates without such jiggery-pokery.

	    open (BLOG, $blogfile) or push (@errors, "An error occured: 
couldn't open blog file.");

why are you using files when your needs would be much better served with 
a proper database?


open (COUNT, ">$countfile") or push (@errors, "An error occured during 
posting: couldn't open count file.");
			flock (COUNT, LOCK_EX) or push (@errors, "An error occured during 
posting: couldn't lock count file.");

your open fails and you save the error (but not $!, which would tell you 
what the error is), yet you still continue to the flock. why?


why are you printing html directly from perl? *please* look at (and 
understand, and use) templating solutions.

Mark


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

Date: 02 May 2004 22:17:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: OSs with Perl installed
Message-Id: <slrnc9asr8.egl.abigail@alexandra.abigail.nl>

Matt Garrish (matthew.garrish@sympatico.ca) wrote on MMMDCCCXCVII
September MCMXCIII in <URL:news:6LZkc.51312$k%.1310890@news20.bellglobal.com>:
//  
//  "Abigail" <abigail@abigail.nl> wrote in message
//  news:slrnc98g8e.egl.abigail@alexandra.abigail.nl...
// >
// > What I want isn't relevant - Microsoft isn't targetting me. But for
// > anyone preferring Perl, there are 1,000 people preferring Movie Maker.
// > The fast majority of the computer users are just users. They aren't
// > programming. They have as little interest in having Perl on their
// > systems, as they have in having a C compiler, of Visual Basic, or
// > Java development tools.
// >
//  
//  1,000 people who prefer Movie Maker for *personal use*. I don't believe for
//  a minute that Linux (or any OS I can think of) is any immediate threat to
//  Microsoft in that regard. As an OS in a work environment, however, Windows
//  is garbage. Aside from all the security holes that keep our tech support
//  group running around after viruses, the systems just don't work. Worse, the
//  so-called "mcse" people don't have a clue how to fix them. The sad reality
//  is their answer to everything is to re-install the system (and what choice
//  do you have half the time anyway, it's faster than trying to debug).
//  Microsoft's advantage was the difficulty of use of other operating systems
//  at the time, plus the notion they pushed that any idiot could maintain them
//  (i.e., dump your high priced unix specialists).

Despite Windows being classified as "garbage", it's still actively 
being used by your company. I rest my case.


Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


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

Date: Sun, 2 May 2004 22:42:26 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Regexp question...
Message-Id: <c73tdi$5rf$1@news.simnet.is>

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:c73pbp$hc3kj$1@ID-184292.news.uni-berlin.de...
> gnari wrote:
> > Gunnar Hjalmarsson wrote:
> >>Ala Qumsieh wrote:
> >>
> >>>    $select =~ s/\Q||','||\E$//;
> >>
> >>- \E right before $ is apparently redundant.
> >
> > apparently not
>
> Okay.. Guess "apparently" was a bad choice of word. ;-)  New try:
>
> - \E right before $ is redundant.

you misunderstand. I was not commenting on your wording,
but on your meaning. I am saying you are wrong.
the \E is not redundant.

gnari






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

Date: Mon, 03 May 2004 01:54:31 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regexp question...
Message-Id: <c741v2$hpnc1$1@ID-184292.news.uni-berlin.de>

gnari wrote:
> Gunnar Hjalmarsson wrote:
>> gnari wrote:
>>> Gunnar Hjalmarsson wrote:
>>>> Ala Qumsieh wrote:
>>>>> 
>>>>>     $select =~ s/\Q||','||\E$//;
>>>> 
>>>> - \E right before $ is apparently redundant.
>>> 
>>> apparently not
>> 
>> Okay.. Guess "apparently" was a bad choice of word. ;-)  New try:
>> 
>> - \E right before $ is redundant.
> 
> you misunderstand. I was not commenting on your wording, but on
> your meaning. I am saying you are wrong. the \E is not redundant.

??

Aha, now I understand. Since $ is a pattern metacharacter, \E *is*
needed, or else the pattern would not match without the literal
character $ being included in the string.

My bad. I should know better than questioning an answer to a regex
question without tests.

Thanks, gnari! Sorry for any confusion my comment may have caused.

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



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

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


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