Kastagire has asked for the wisdom of the Perl Monks concerning the following question:
I am having a bit of a quandary, as I am a complete Perl newbie, and the answer to my question is probably an easy one. In short, I have a c++ app that calls a Perl script from the command prompt. When we call the script, we need to specify several variables, like name and IP address, which I need to be variables that can be passed in. How can I accomplish this? I would like to continue to use the command window as it is, just somehow add the variables in place of "name" and "IPAddress". If you could, please provide a code example of what it should look like. This is just a small part that will be added to a much larger application, and this is how the architect wants it done. Any help you can give me would be awesome!!!
Thanks!My code follows...
#include<iostream> #include<stdlib.h> #include<stdio.h> #include<string> #include<fstream> using namespace std; int main() { string fName; string lName; string IPAddress; bool created; cout << "First Name: " << endl; cin >> fName; cout << "Last Name: " << endl; cin >> lName; system("cmd.exe /C \"c:\\Program Files\\Forterra\\OLIVE SDK 2.0.1\ +\util\\legacy\\src\\Tool\\AddAvatar.pl\" --name=Bacon N Eggs --host=1 +27.0.0.1:9911"); // created = true; if (created == true) { cout << "Your Avatar's name is: " << fName << " " << lName << + endl; ofstream aviFile("aviList.txt", ios::app); aviFile << fName << " " << lName << endl; aviFile.close(); } else { cout <<"Your avatar was not able to be created or already exis +ts. Contact your system administrator"<< endl; } system("pause"); return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing C++ variable into Perl in command line
by jethro (Monsignor) on Jul 24, 2008 at 17:09 UTC | |
|
Re: Passing C++ variable into Perl in command line
by toolic (Bishop) on Jul 24, 2008 at 16:57 UTC | |
|
Re: Passing C++ variable into Perl in command line
by ikegami (Patriarch) on Jul 24, 2008 at 20:31 UTC | |
|
Re: Passing C++ variable into Perl in command line
by moritz (Cardinal) on Jul 24, 2008 at 16:52 UTC | |
|
Re: Passing C++ variable into Perl in command line
by spivey49 (Monk) on Jul 24, 2008 at 18:04 UTC |