Visit the LQ Articles and Editorials section
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-28-2004, 03:40 AM   #1
LQ Newbie
Registered: Jul 2004
Posts: 6

Rep: Reputation: 0
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:
./$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.
Old 08-28-2004, 09:46 AM   #2
Senior Member
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
If you have not figured out yet, try the system() command, like

system($EXE, $ARGV[0], $ARGV[1],...)
Old 08-28-2004, 11:29 PM   #3
LQ Newbie
Registered: Jul 2004
Posts: 6

Original Poster
Rep: Reputation: 0
i dont get any error messages, and the script runs through, but it appears that the $EXE i specify does not run.
: /
Old 08-29-2004, 12:31 AM   #4
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
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)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Directory listing - Calling shell script from a CGI script seran Programming 6 08-12-2005 12:08 AM
Issues calling sort from perl using pipe as delimiter amytys Programming 1 10-20-2004 10:35 PM
calling sys_read inside sys_write returns number of bytes read as zero appas Linux - Software 0 08-28-2004 08:21 AM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 11:22 AM
calling subs from within Perl bickford Programming 8 08-13-2000 08:10 PM

All times are GMT -5. The time now is 09:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration