Thread: code to run (linux) programs WITH arguments

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    10

    code to run (linux) programs WITH arguments

    I'd need a function or code to run linux programs with arguments from my C++ program.
    e.g.
    "Run> someapp 1 2 3 -a -b".
    Thanks for all answers!!

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The same way you always do. Linux is nothing special in this respect:

    int main( int argc, char *argv[] )

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    10

    you got me wrong

    That's not what I wanted to know! ;-)
    My question wasn't good. I mean, I write a program like this:

    int main()
    {
    int x, y;
    cout<<"Program you want to run:";
    cin>>x;
    cout<<"Arguments:";
    cin>>y;

    <code to run x with y>
    }

    I hope you understand what I mean!!!

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    1
    Take a look at the "exec" functions. They will do what you want. Do a "man execlp" for help.
    Last edited by dmwarak; 12-27-2001 at 03:39 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Thinking of upgrading to linux...
    By Yarin in forum General Discussions
    Replies: 37
    Last Post: 07-24-2009, 11:40 AM
  2. Lines from Unix's source code have been copied into the heart of Linux????
    By zahid in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 05-19-2003, 03:50 PM
  3. Replies: 5
    Last Post: 04-17-2003, 07:07 AM
  4. True ASM vs. Fake ASM ????
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 04-02-2003, 04:28 AM
  5. Linux OS to Windows OS code
    By sw9830 in forum C Programming
    Replies: 2
    Last Post: 02-28-2003, 03:11 PM