Click here to Skip to main content
15,900,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have c language file with my algorithm in it and I have done command line arguments. I have compiled the file and got the assembler output file also. Now I need to pass values to my output of c file from perl script and get back the values from c file. Need help.
thanks in advance.

What I have tried:

I am not very familiar with perl scripting.
Posted
Updated 26-Mar-17 23:52pm
Comments
Garth J Lancaster 27-Mar-17 5:39am    
just to clarify

a) you have a 'c' program
b) the 'c' program takes command line arguments
c) the 'c' program works
d) the 'c' program returns values via ?stdout
e) you wish to call the 'c' program from perl, pass the 'c' program arguments, and collect its output

'd' is the one you havnt really described well - how does the 'c' program return data -
f) as an exit code (if its just an integer for example)
g) as a file
h) it writes to stdout

confirming (or not) that understanding may help us help you

oh, and, are you running on Windows, *nix, .....
R!sh! 27-Mar-17 5:43am    
sorry for not providing proper information. C file just prints the output. That output I need. Code is such that, once the data is printed it will stop execution and your clarification is correct.
R!sh! 27-Mar-17 5:44am    
I am using linux( fedora 22)
Garth J Lancaster 27-Mar-17 5:53am    
I posted a solution below using 'backticks' - many ways to skin a cat in Perl there is
Richard MacCutchan 27-Mar-17 5:39am    
You just add the parameters to the command line of your executable file:

your.exe param1 param2 ... paramN

As to learning Perl, Google will find you many references.

You may find many examples and tutorials on the web, just using Google. See, for instance:
Running external programs from Perl with system[^].
 
Share this answer
 
you may need to try a few different approaches - in Perl there are heaps of options - as others have said, Google would find some, but, here's a simple one, using 'backticks'

PERL
my $str = `your-prog arg1 arg2 .. argn`;


$str will hold the result ('stdout') from your-prog
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900