in reply to need help to passing argument to executable and get return the result

You can do it like
open (IN,"| hellop.pl $my_value") or ...... ; my @retvals = <IN> ; # or do it with a while(<IN>){} close IN ;
hello.pl can access the value via $ARGV[0]

But be careful with processing user input! For example, what if $my_value contains '10 | rm -rf /' ( maybe the '|' should be a ';', I don't know, but I'm not a hacker)
Than you can as well do @retvals = `hello.pl $my_value`

I think you see the poin!

LuCa

Replies are listed 'Best First'.
Re^2: need help to passing argument to executable and get return the result
by jeanluca (Deacon) on Aug 19, 2006 at 09:15 UTC
    see the CGI manual, the example are really good!!

    LuCa
      Thanks luca..
      now tell me can i do this
      my $q=$ARGV[0]; my $offset=$ARGV[1];

      if i'm passing two arguments

      Thanks

        Good heavens no! Good thing you didn't try that code to see what it would do! I mean if you'd actually tried running the code to see what might happen you could have ripped a hole in the space-time continuum sending the entire Lesser Magellanic Cloud off into the 11th dimension.

        Or maybe you'd have just gotten an error. Or it might have worked the way the documentation you should have read would indicate. Who knows.

        Well, not you of course since you didn't try it.

        yep, thats one way!
        But this will probably work too
        my ($q, $offset) = @ARGV ;
        But be careful testing your code using my previous example as already mentioned by Fletch :)
Re^2: need help to passing argument to executable and get return the result
by ashwani (Initiate) on Aug 19, 2006 at 08:33 UTC
    thanks LuCa...
    but i could not get how can i access the textbox value in print.pl as tedpride say.
    i said there is print.pl or print.cgi having html code and showing textbox so how will this print.cgi get that textbox value.
    ted pride give hardcode value.
    if you know cgi->param('q') i need to know about that.
    thanks