?
Solved

Executing another application with parameters

Posted on 2007-08-10
5
Medium Priority
?
178 Views
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);

system(seg);

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.
0
Comment
Question by:DanPerlman
5 Comments
 
LVL 13

Accepted Solution

by:
josgood earned 375 total points
ID: 19674580
char s[11] = "10 20 30 50";
11 is too short.
Use
char s[] = "10 20 30 50";

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

Assisted Solution

by:ravenpl
ravenpl earned 375 total points
ID: 19675048
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.
0
 
LVL 85

Assisted Solution

by:ozo
ozo earned 375 total points
ID: 19677640
If you want to execute restoreit  with out the parameters, why not call system without calling strcat?
0
 
LVL 18

Assisted Solution

by:Jinesh Kamdar
Jinesh Kamdar earned 375 total points
ID: 19679926
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.
0
 

Author Comment

by:DanPerlman
ID: 19685160
We figured it out. This was being compiled on a SCO box and we were having issues with the file being parsed.
0

Featured Post

Free tool for managing users' photos in Office 365

Easily upload multiple users’ photos to Office 365. Manage them with an intuitive GUI and use handy built-in cropping and resizing options. Link photos with users based on Azure AD attributes. Free tool!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
There's never been a better time to become a computer scientist. Employment growth in the field is expected to reach 22% overall by 2020, and if you want to get in on the action, it’s a good idea to think about at least minoring in computer science …
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

600 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