How to call another program

Discussion in 'Perl Misc' started by David Grey, May 2, 2004.

  1. David Grey

    David Grey Guest

    How do you call another program from within the perl script
    and not loose control. When I try:

    #!/usr/bin/perl

    $Query_File = $ENV{QUERY_STRING};

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

    it goes to domain.com and that is the last it is heard from, and
    for some reason you have to put something like:
    $Query_File = $ENV{QUERY_STRING};

    in or all you get is an error. I am sure there is a command that
    allows you to call another program from another domain then
    come back and finish the job. Can you use LWP::UserAgent;
    to execute a program and then have the rest of the program
    finish what it is doing afterward?
     
    David Grey, May 2, 2004
    #1
    1. Advertising

  2. David Grey

    Tony Curtis Guest

    >> On Sun, 02 May 2004 16:07:00 GMT,
    >> David Grey <> said:


    > How do you call another program from within the perl script
    > and not loose control. When I try:


    > #!/usr/bin/perl


    use strict;
    use warnings;

    > $Query_File = $ENV{QUERY_STRING};


    "perldoc CGI" to handle submitted data cleanly.

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


    > it goes to domain.com and that is the last it is heard from,


    That's correct behaviour.

    > and for some reason you have to put something like:
    > $Query_File = $ENV{QUERY_STRING}; in or all you get is an
    > error.


    I'm afraid that is nonsense.

    > I am sure there is a command that allows you to call another
    > program from another domain then come back and finish the
    > job. Can you use LWP::UserAgent; to execute a program and
    > then have the rest of the program finish what it is doing
    > afterward?


    You don't "call another program", you submit data to a URL.
    (There might be a program of some kind implementing the
    response to you from wherever the request is handled, but that
    is irrelevant.)

    "perldoc lwpcook" has various examples for LWP. Construct the
    request and send it off. Parse the response for what you need
    and carry on processing...

    hth
    t
     
    Tony Curtis, May 2, 2004
    #2
    1. Advertising

  3. David Grey wrote:
    > How do you call another program from within the perl script


    perldoc -f system
    perldoc -f exec
    perldoc perlop and look for qx
    ....

    > and not loose control.


    Well, not sure what you mean by "loose control" but I'm guessing mabye you
    want to execute you script and the other program in parallel? Then use
    fork() to spawn a new process and then exec() to the other program in the
    child process. That way the parent process can still do whatever it wants to
    do.

    > When I try:
    >
    > #!/usr/bin/perl
    >
    > $Query_File = $ENV{QUERY_STRING};
    >
    > print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
    >
    > it goes to domain.com and that is the last it is heard from, and
    > for some reason you have to put something like:
    > $Query_File = $ENV{QUERY_STRING};
    >
    > in or all you get is an error. I am sure there is a command that
    > allows you to call another program from another domain


    What is "call another program from another domain" supposed to mean?
    There are no domains in Perl programs.

    > then
    > come back and finish the job. Can you use LWP::UserAgent;
    > to execute a program and then have the rest of the program
    > finish what it is doing afterward?


    What does all this have to do with executing program?

    jue
     
    Jürgen Exner, May 2, 2004
    #3
  4. David Grey

    David Grey Guest

    Jürgen Exner wrote:

    > David Grey wrote:
    > > How do you call another program from within the perl script

    >
    > perldoc -f system
    > perldoc -f exec
    > perldoc perlop and look for qx
    > ...
    >
    > > and not loose control.

    >
    > Well, not sure what you mean by "loose control" but I'm guessing mabye you
    > want to execute you script and the other program in parallel? Then use
    > fork() to spawn a new process and then exec() to the other program in the
    > child process. That way the parent process can still do whatever it wants to
    > do.




    Would this be getting close:

    while (-1) {

    sleep 3;
    forktest();
    sleep 12;
    }

    # The rest of the program below

    sub forktest {

    FORK: {

    $Query_File = $ENV{QUERY_STRING};

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

    } return;
    }



    >
    >
    > > When I try:
    > >
    > > #!/usr/bin/perl
    > >
    > > $Query_File = $ENV{QUERY_STRING};
    > >
    > > print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
    > >
    > > it goes to domain.com and that is the last it is heard from, and
    > > for some reason you have to put something like:
    > > $Query_File = $ENV{QUERY_STRING};
    > >
    > > in or all you get is an error. I am sure there is a command that
    > > allows you to call another program from another domain

    >
    > What is "call another program from another domain" supposed to mean?
    > There are no domains in Perl programs.
    >
    > > then
    > > come back and finish the job. Can you use LWP::UserAgent;
    > > to execute a program and then have the rest of the program
    > > finish what it is doing afterward?

    >
    > What does all this have to do with executing program?
    >
    > jue
     
    David Grey, May 2, 2004
    #4
  5. David Grey

    gnari Guest

    "David Grey" <> wrote in message
    news:...
    >

    [snip discussion about execution and fork]

    forget about fork here. that only came up because you
    were talking about 'executing a script', when what
    you want to do is to submit a HTTP request in the
    middle of a cgi process.

    read Tony's post in this thread.

    gnari
     
    gnari, May 2, 2004
    #5
  6. David Grey

    David Grey Guest

    gnari wrote:

    > "David Grey" <> wrote in message
    > news:...
    > >

    > [snip discussion about execution and fork]
    >
    > forget about fork here. that only came up because you
    > were talking about 'executing a script', when what
    > you want to do is to submit a HTTP request in the
    > middle of a cgi process.
    >
    > read Tony's post in this thread.
    >
    > gnari



    It does no good to tell me to go off someplace and look something
    up when I have not a clue what you are saying in the first place,
    and don't have a clue what to look for. We are talking about a
    language here, and it would help if people could show a bit of code
    what you are saying. It is like a christian telling someone it is right
    in Psalms go look it up, well there are 150 chapters in Psalms
    where do you start. (Stating a fact not trying to be gruff.)

    What I need to do is have a script that runs a script first on the
    doman.com that performs a function that has to be done first, then
    continue the script to copy a file produced on the domain.com .
    I want a file from the A machine to the B machine every time a
    html page come up so the data is current every time. I have finally
    worked out everything but running the script on domain.com
    and continuing, it will do one or the other, but not both. The
    running of the script on domain.com must happen first.

    Reading Tony's post in this thread is gibberish, it has no meaning
    at this point, I don't know what he said. What I need is:

    Run script on domain.com

    Wait long enough for that to finish

    continue script

    That's it, the run script on domain.com must happen first.
     
    David Grey, May 2, 2004
    #6
  7. David Grey <> wrote in news::

    > gnari wrote:
    >
    >> read Tony's post in this thread.
    >>
    >> gnari

    >
    >
    > It does no good to tell me to go off someplace and look something
    > up when I have not a clue what you are saying in the first place,
    > and don't have a clue what to look for. We are talking about a
    > language here, and it would help if people could show a bit of code
    > what you are saying. It is like a christian telling someone it is right
    > in Psalms go look it up, well there are 150 chapters in Psalms
    > where do you start. (Stating a fact not trying to be gruff.)


    Tony did put it best (<>):

    >> You don't "call another program", you submit data to a URL.
    >> (There might be a program of some kind implementing the
    >> response to you from wherever the request is handled, but that
    >> is irrelevant.)
    >>
    >> "perldoc lwpcook" has various examples for LWP. Construct the
    >> request and send it off. Parse the response for what you need
    >> and carry on processing...



    > What I need to do is have a script that runs a script first on the
    > doman.com that performs a function that has to be done first, then
    > continue the script to copy a file produced on the domain.com .
    > I want a file from the A machine to the B machine every time a
    > html page come up so the data is current every time.


    Then write it using the examples provided in the docs you have been
    referred to. If you have problems once you actually try to do your own
    work, then you can come back and ask.

    > I have finally worked out everything


    Apparently not. You have a lot of reading to do to understand how HTTP
    works.

    > Reading Tony's post in this thread is gibberish, it has no meaning
    > at this point, I don't know what he said.


    Nice attitude. That'll get you a lot of help around here.

    > What I need is:
    >
    > Run script on domain.com
    >
    > Wait long enough for that to finish
    >
    > continue script
    >
    > That's it, the run script on domain.com must happen first.


    Did you actually take a look at:

    http://search.cpan.org/~gaas/libwww-perl-5.79/lib/LWP/Simple.pm

    You should also be able to access it on your computer using

    perldoc LWP::Simple

    If you have made it this far, the following might help:

    #! perl

    use strict;
    use warnings;

    $| = 1;

    use CGI qw/ :cgi /;
    $CGI::pOST_MAX = 1024;
    $CGI::DISABLE_UPLOADS = 1;

    use HTML::Entities;
    use LWP::Simple;

    use Regexp::Common qw/ URI /;

    my $url = param('url');
    $url = (defined $url ? $url : '');

    if( $url =~ /^$RE{URI}{HTTP}{-keep}$/ ) {
    my $content = get($1);
    if(defined $content) {
    show_results(HTML::Entities::encode($content));
    } else {
    show_form();
    }
    } else {
    show_form();
    }


    sub show_form {
    print header();
    print<<END;
    <html>
    <head><title>Get Source</title></head>
    <body>
    <form>
    <p>
    URL:&nbsp;<input type="text" name="url" size="40">
    <input type="submit">
    </form>
    </p>
    </body>
    </html>
    END

    }

    sub show_results {
    my ($content) = @_;

    print header();
    print<<END;
    <html>
    <head><title>Got Source!</title></head>
    <form>
    <p>
    URL:&nbsp;<input type="text" name="url" size="40">
    <input type="submit">
    </form>
    <h1>Results from previous request</h1>
    <pre>
    $content
    </pre>
    </body>
    </html>
    END

    }
    __END__



    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, May 2, 2004
    #7
  8. David Grey

    David Grey Guest

    A. Sinan Unur wrote:

    > David Grey <> wrote in news::
    >
    > > gnari wrote:


    >
    >
    > > What I need is:
    > >
    > > Run script on domain.com
    > >
    > > Wait long enough for that to finish
    > >
    > > continue script
    > >
    > > That's it, the run script on domain.com must happen first.

    >
    > Did you actually take a look at:
    >
    > http://search.cpan.org/~gaas/libwww-perl-5.79/lib/LWP/Simple.pm
    >
    > You should also be able to access it on your computer using
    >
    > perldoc LWP::Simple
    >
    > If you have made it this far, the following might help:
    >
    > #! perl
    >
    > use strict;
    > use warnings;
    >
    > $| = 1;
    >
    > use CGI qw/ :cgi /;
    > $CGI::pOST_MAX = 1024;
    > $CGI::DISABLE_UPLOADS = 1;
    >
    > use HTML::Entities;
    > use LWP::Simple;
    >
    > use Regexp::Common qw/ URI /;
    >
    > my $url = param('url');
    > $url = (defined $url ? $url : '');
    >
    > if( $url =~ /^$RE{URI}{HTTP}{-keep}$/ ) {
    > my $content = get($1);
    > if(defined $content) {
    > show_results(HTML::Entities::encode($content));
    > } else {
    > show_form();
    > }
    > } else {
    > show_form();
    > }
    >
    > sub show_form {
    > print header();
    > print<<END;
    > <html>
    > <head><title>Get Source</title></head>
    > <body>
    > <form>
    > <p>
    > URL:&nbsp;<input type="text" name="url" size="40">
    > <input type="submit">
    > </form>
    > </p>
    > </body>
    > </html>
    > END
    >
    > }
    >
    > sub show_results {
    > my ($content) = @_;
    >
    > print header();
    > print<<END;
    > <html>
    > <head><title>Got Source!</title></head>
    > <form>
    > <p>
    > URL:&nbsp;<input type="text" name="url" size="40">
    > <input type="submit">
    > </form>
    > <h1>Results from previous request</h1>
    > <pre>
    > $content
    > </pre>
    > </body>
    > </html>
    > END
    >
    > }
    > __END__
    >
    > -


    That is not what I want to do (from what I can tell) I want to :

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

    run this script before running the rest of the script. When I run the
    above it goes off and does not run the rest of the script that this
    is in.
     
    David Grey, May 2, 2004
    #8
  9. David Grey <> wrote in news::

    > That is not what I want to do (from what I can tell) I want to :
    >
    > print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";


    Why this attachment to the redirect?

    > run this script before running the rest of the script. When I run the
    > above it goes off and does not run the rest of the script that this
    > is in.


    I see no indication that you have read any of the responses.
    By definition, that line will _redirect_ the request to

    http://www.domain.com/cgi-bin/copyprog.pl

    That's it. Basically, you can't have your cake and eat it too. You are
    telling the user's browser to go fetch a different page than yours and
    you are wondering why she has left you.

    Do you live in an area with high lead concentration?
    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, May 2, 2004
    #9
  10. David Grey

    David Grey Guest

    A. Sinan Unur wrote:

    > David Grey <> wrote in news::
    >
    > > That is not what I want to do (from what I can tell) I want to :
    > >
    > > print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";

    >
    > Why this attachment to the redirect?


    I want it to run the script above. Redirect does it, but it wont run
    the rest of the script. I don't know of any other way, that is why
    I am here.

    >
    >
    > > run this script before running the rest of the script. When I run the
    > > above it goes off and does not run the rest of the script that this
    > > is in.

    >
    > I see no indication that you have read any of the responses.


    Reading a post in german does little to know what they said, I
    said I had not a clue what they were saying and you took that
    as an insult. If you don't know that they are saying, you don't
    what they are saying period.

    > By definition, that line will _redirect_ the request to
    >
    > http://www.domain.com/cgi-bin/copyprog.pl
    >
    > That's it. Basically, you can't have your cake and eat it too. You are
    > telling the user's browser to go fetch a different page than yours and
    > you are wondering why she has left you.


    I want the the script to run the above script, I don know any other
    way, so far everyone instead of telling me says go look it
    up yourself. If I don't know what to look up I can't look it up.

    >
    >
    > Do you live in an area with high lead concentration?


    No just an area where you expect me to run before I even know
    how to walk. If you want to just be abusive and not help, I'm
    sure you would be welcomed in any flame group. I don't see the
    point of it here, if I knew what I was doing I would not be here.
     
    David Grey, May 2, 2004
    #10
  11. David Grey <> wrote in news::

    > A. Sinan Unur wrote:
    >
    >> David Grey <> wrote in news::
    >>
    >> > That is not what I want to do (from what I can tell) I want to :
    >> >
    >> > print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";

    >>
    >> Why this attachment to the redirect?

    >
    > I want it to run the script above. Redirect does it, but it wont run
    > the rest of the script. I don't know of any other way, that is why
    > I am here.


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

    > if I knew what I was doing I would not be here.


    You need to at least know something about what you are doing and be
    willing to learn and do some work on your own.

    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, May 2, 2004
    #11
  12. David Grey

    Tony Curtis Guest

    >> On Sun, 02 May 2004 20:54:23 GMT,
    >> David Grey <> said:


    > A. Sinan Unur wrote:


    >> David Grey <> wrote in
    >> news::
    >>
    >> > That is not what I want to do (from what I can tell) I

    >> want to :
    >> >
    >> > print "Location:

    >> http://www.domain.com/cgi-bin/copyprog.pl\n\n";
    >>
    >> Why this attachment to the redirect?


    > I want it to run the script above. Redirect does it, but it
    > wont run the rest of the script. I don't know of any other
    > way, that is why I am here.


    No, you want to GET (I assume) the URL above, and process the
    response in some way.

    > Reading a post in german does little to know what they said,


    Jeepers, I *do* speak German! That's spooky.

    > I want the the script to run the above script, I don know
    > any other way, so far everyone instead of telling me says go
    > look it up yourself. If I don't know what to look up I can't
    > look it up.


    perldoc lwpcook, it has examples of building requests and
    handling the responses.

    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. 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.
     
    Tony Curtis, May 2, 2004
    #12
  13. David Grey

    David Grey Guest

    Tony Curtis wrote:

    > >> On Sun, 02 May 2004 20:54:23 GMT,
    > >> David Grey <> said:

    >
    > > A. Sinan Unur wrote:

    >
    > >> David Grey <> wrote in
    > >> news::
    > >>
    > >> > That is not what I want to do (from what I can tell) I
    > >> want to :
    > >> >
    > >> > print "Location:
    > >> http://www.domain.com/cgi-bin/copyprog.pl\n\n";
    > >>
    > >> Why this attachment to the redirect?

    >
    > > I want it to run the script above. Redirect does it, but it
    > > wont run the rest of the script. I don't know of any other
    > > way, that is why I am here.

    >
    > 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.

    >
    >
    > > Reading a post in german does little to know what they said,

    >
    > Jeepers, I *do* speak German! That's spooky.


    I don't though, so posting in a language I don't know then
    faulting me for not knowing the language is not fruitful.

    >
    >
    > > I want the the script to run the above script, I don know
    > > any other way, so far everyone instead of telling me says go
    > > look it up yourself. If I don't know what to look up I can't
    > > look it up.

    >
    > 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.
     
    David Grey, May 2, 2004
    #13
  14. David Grey

    David Grey Guest

    A. Sinan Inner wrote:

    > David Grey <> wrote in news::
    >
    > > A. Sinan Unur wrote:
    > >
    > >> David Grey <> wrote in news::
    > >>
    > >> > That is not what I want to do (from what I can tell) I want to :
    > >> >
    > >> > print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
    > >>
    > >> Why this attachment to the redirect?

    > >
    > > I want it to run the script above. Redirect does it, but it wont run
    > > the rest of the script. I don't know of any other way, that is why
    > > I am here.

    >
    > 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.

    >
    >
    > > if I knew what I was doing I would not be here.

    >
    > You need to at least know something about what you are doing and be
    > willing to learn and do some work on your own.


    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 cannot look up what you have 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, not get a file as it seems you posted.
    I need to run a script at domain.com in a script, period.
     
    David Grey, May 2, 2004
    #14
  15. David Grey

    Tony Curtis Guest

    >> On Sun, 02 May 2004 21:45:16 GMT,
    >> David Grey <> 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.) You want to collect what was output and then do
    something else.
     
    Tony Curtis, May 2, 2004
    #15
  16. David Grey 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


    So what do you think is going to happen when you send a GET request, magic?
    The server at the other end *runs* *the* *script* to service the request
    you sent.

    >> 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.


    Send a GET request to the URL - that's been explained several times now, so
    I won't repeat it.

    To handle that request, the remote server runs the script. If you don't care
    about the output, fine - just ignore it or throw it away. The point is, by
    fetching the URL yourself, instead of telling the browser to fetch it, your
    script can wait for the other one to finish, and then send the browser
    whatever output you want to send it.

    >> 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)


    Now who's being abusive? The people who have been advising you are not
    spouting gibberish like "dlksj" just to confuse you. They're using clear,
    concise technical terms that you happen to be unfamiliar with. They're
    trying hard to help you, and you're being an ungrateful brat in return.
    Nice.

    > I want to dlksj the script on the domain.com and continue the process.
    > Nothing more, nothing less.


    Forget about the Location: then, and stop yelling at the kind people who
    have been trying to help you. The biggest obstacle in your way right now is
    your own stubborn refusal to learn.

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, May 2, 2004
    #16
  17. On Sun, 02 May 2004 21:35:53 GMT, David Grey <> 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.
     
    John J. Trammell, May 2, 2004
    #17
  18. David Grey <> wrote in news::

    > 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
    (reverse each component for email address)
     
    A. Sinan Unur, May 2, 2004
    #18
  19. 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.
     
    Alan J. Flavell, May 2, 2004
    #19
  20. "John J. Trammell" <> wrote in
    news:-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
    (reverse each component for email address)
     
    A. Sinan Unur, May 2, 2004
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Nolan
    Replies:
    4
    Views:
    11,034
    E. Robert Tisdale
    Apr 8, 2004
  2. Jung Joon Park

    Another program call - Need help

    Jung Joon Park, Aug 1, 2005, in forum: C++
    Replies:
    1
    Views:
    303
    Srini
    Aug 2, 2005
  3. Ben Keshet

    Pyhton script to call another program

    Ben Keshet, May 6, 2009, in forum: Python
    Replies:
    1
    Views:
    301
    Diez B. Roggisch
    May 6, 2009
  4. Rob R. Ainscough
    Replies:
    3
    Views:
    344
    Rob R. Ainscough
    Jun 14, 2005
  5. sonet

    Call another program using system

    sonet, Jan 25, 2007, in forum: Perl Misc
    Replies:
    2
    Views:
    94
    Brian McCauley
    Jan 25, 2007
Loading...

Share This Page