Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: need help to passing argument to executable and get return the result

by TedPride (Priest)
on Aug 19, 2006 at 07:35 UTC ( #568320=note: print w/ replies, xml ) Need Help??


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

You can call an executable installed on your system by using `script path`, and you can pass it a value by doing `script path arguments`. The script (if it's Perl) can then access these arguments the regular way, through @ARGV, and print a result, and you should be able to access the result if you did $var = `script path arguments`. I'll go test this now and see if my memory works properly :)

## print.pl my $arguments = 'beep'; my $var = `perl process.pl $arguments`; print $var;
## process.pl my $var = shift @ARGV; $var = uc($var); print $var;
If I do perl print.pl, I get the result BEEP, which means it's passing back and forth properly.


Comment on Re: need help to passing argument to executable and get return the result
Select or Download Code
Replies are listed 'Best First'.
Re^2: need help to passing argument to executable and get return the result
by ashwani (Initiate) on Aug 19, 2006 at 07:58 UTC
    Thanks TedPride it was really very helpful.
    can you solve one more thing?
    if there are four argument then how will process.pl handle it?
    Thanks again
      ted pride i used ur code it is working properly.Thanks
      but i got error when i pass both parameter but one is blank so this code could not handle that condition and i trapped in this.
      $output='xyz.pl $param1 $param2'; where $param1=''; $param2=0;
      i'm not getting how can i handle it.
      my ($x,$y)=@argv;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://568320]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2015-07-08 02:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls