LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   calling a c++ binary inside a perl script (http://www.linuxquestions.org/questions/programming-9/calling-a-c-binary-inside-a-perl-script-223396/)

Blue_muppet 08-28-2004 02:40 AM

calling a c++ binary inside a perl script
 
Hi all

I have a c++ program that is called 'sim' that takes 6 parameters
invoked at shell by typing './sim <x> <y> <z> <a> <b> <c>'

i would like to call it inside my perl script (very much a n00b here), how do i go about that?

futhermore, i would like to pass parameters to it when the perl script is invoked. Do i do that by just going:
Code:

./$EXE @ARGV[0] @ARGV[1] @ARGV[2] @ARGV[3] @ARGV[4] @ARGV[5];
Obviously with './$EXE' replaced with what u actually use in perl to call a c++ program.

OS is unix.

Cedrik 08-28-2004 08:46 AM

If you have not figured out yet, try the system() command, like

system($EXE, $ARGV[0], $ARGV[1],...)

Blue_muppet 08-28-2004 10:29 PM

i dont get any error messages, and the script runs through, but it appears that the $EXE i specify does not run.
: /

aluser 08-28-2004 11:31 PM

see "perldoc -f system" for how to get the error code out of system() if it's not working. If you had been running an executable out of the current directory like "./foo", you'll still need the "./" in the system() call, e.g. system("./$EXE", $arg1, $arg2)


All times are GMT -5. The time now is 09:45 PM.