473,410 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

How to call an external command?

Hi, everyone,

Now I need to execute an external command in my C program. For
example, the dos command is "lp_solve -p < LP1.txt". I want to execute
this command in my C program so as to obtain certain result, and then
continue to execute the C codes. But I have no idea how to manage it.
Could anyone please give me some hints one this problem? Thanks in
advance!

VB
/Cris
Nov 14 '05 #1
4 2521
Cris Ding <cr*******@mh.se> scribbled the following:
Hi, everyone, Now I need to execute an external command in my C program. For
example, the dos command is "lp_solve -p < LP1.txt". I want to execute
this command in my C program so as to obtain certain result, and then
continue to execute the C codes. But I have no idea how to manage it.
Could anyone please give me some hints one this problem? Thanks in
advance!


You'll want system().

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"I will never display my bum in public again."
- Homer Simpson
Nov 14 '05 #2
nrk
Cris Ding wrote:
Hi, everyone,

Now I need to execute an external command in my C program. For
example, the dos command is "lp_solve -p < LP1.txt". I want to execute
this command in my C program so as to obtain certain result, and then
continue to execute the C codes. But I have no idea how to manage it.
Could anyone please give me some hints one this problem? Thanks in
advance!

VB
/Cris


You happen to be in luck. This is part of the CLC FAQ:

http://www.eskimo.com/~scs/C-faq/q19.27.html

Please take the time to read through the rest of the fine FAQ before posting
further questions:
http://www.eskimo.com/~scs/top.html

-nrk.

--
Remove devnull for email
Nov 14 '05 #3
cr*******@mh.se (Cris Ding) wrote:
# Hi, everyone,
#
# Now I need to execute an external command in my C program. For
# example, the dos command is "lp_solve -p < LP1.txt". I want to execute
# this command in my C program so as to obtain certain result, and then
# continue to execute the C codes. But I have no idea how to manage it.
# Could anyone please give me some hints one this problem? Thanks in

You should look up the system() function.
rc = system("lp_solve -p < LP1.txt");
will parse the string, execute the command, and return a response code
if your system implements this function.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
You face forward, or you face the possibility of shock and damage.
Nov 14 '05 #4
Derk Gwen <de******@HotPOP.com> wrote in message news:<10*************@corp.supernews.com>...
cr*******@mh.se (Cris Ding) wrote:
# Hi, everyone,
#
# Now I need to execute an external command in my C program. For
# example, the dos command is "lp_solve -p < LP1.txt". I want to execute
# this command in my C program so as to obtain certain result, and then
# continue to execute the C codes. But I have no idea how to manage it.
# Could anyone please give me some hints one this problem? Thanks in

You should look up the system() function.
rc = system("lp_solve -p < LP1.txt");
will parse the string, execute the command, and return a response code
if your system implements this function.


OK, it works. Thank you guys very much!

VB
/Cris
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ayesha Ahsan | last post by:
Hi, I use Runtime.getRuntime().exec(command) to make my system call. For Windows based Dos, i add "cmd /c" before I type in my system call. So for example make the system call "dir": String...
10
by: Sanyi Benczik | last post by:
Is there a standard way in C++ to call an external program or is this platform dependent? If it is platform dependent, can somebody drop a line what to use or where to look for info for GNU C++...
1
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one...
0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
3
by: Niko Schwarz | last post by:
Hello, I'd like to run check from within my c program a gnupg signature. The easiest way should be to simply call gnupg, right? But how do i get the output of that program into a string? best...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
3
by: 4.spam | last post by:
Hello. v8.2.1, Windows. I have a default installation on Windows where instance owner has administrative rights in the system. In this case user with only CREATE_EXTERNAL_ROUTINE authority and...
2
by: Serman D. | last post by:
Hi all, I'm trying to complete the samples from the excellent 2003 developerWorks article "Bringing the Power of Regular Expression Matching to SQL" by Knut Stolze: http://tinyurl.com/3bhrnn...
2
by: iamdennis | last post by:
Hi all. I stuck here and need some help. I have created a combo box which contains a list of links to external PDF files. I also created a OPEN command button next to the combo box. I want to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.