Executing another application with parameters

Posted on 2007-08-10
Last Modified: 2013-11-05
I am having difficulty executing another executable within my app. i am useing system() to invoke the other application. Currently i have something like this:

char seg[27] = "./restoreit ";
char s[11] = "10 20 30 50";

strcat(seg, s);


the issue i have is it try to execute restoreit but with out the parameters that i appended to it. if i print out the array i see the parameters this way. i have also tried inserting " with in string and that does not work either. Thanks in advance.
Question by:DanPerlman
    LVL 13

    Accepted Solution

    char s[11] = "10 20 30 50";
    11 is too short.
    char s[] = "10 20 30 50";

    I don't quite understand the problem you're having.  Could you say it again another way?
    LVL 43

    Assisted Solution

    And can You print seg before system(seg). Does it contain what You wanted?
    Also, Your strings are too short, You should keep eye on that, it's the basic mistake which leads to SIGSEGV and buffer overrun attack.
    LVL 84

    Assisted Solution

    If you want to execute restoreit  with out the parameters, why not call system without calling strcat?
    LVL 18

    Assisted Solution

    by:Jinesh Kamdar
    What kind of an error does it throw? What kind of parameters does restoreit expect? Maybe restoreit is 1 of ur own programs in which the arguments are not being parsed in the right order. Please elaborate.

    Author Comment

    We figured it out. This was being compiled on a SCO box and we were having issues with the file being parsed.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
    This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now