473,749 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do i Run programs

Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it

for example i want to to make a program that run other file call
try.exe and save all the stdout into a file
thanx

May 28 '07 #1
26 2307
Chief skrev:
Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it

for example i want to to make a program that run other file call
try.exe and save all the stdout into a file
thanx
I'm not sure what you mean, but this is my guess:

your_program.ex e < input_file output_file

output_file ll contain same thing that you would see on your dos/shell
window
May 28 '07 #2
On 28 Maj, 13:36, Carramba <u...@example.n etwrote:
Chief skrev:Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it
for example i want to to make a program that run other file call
try.exe and save all the stdout into a file
thanx

I'm not sure what you mean, but this is my guess:

your_program.ex e < input_file output_file

output_file ll contain same thing that you would see on your dos/shell
window
exec*() functions

May 28 '07 #3
Chief wrote:
>
Hello i would like to know which syntax do i have to use in order
? to make a program run other *.exe program and also how to put
inputs in it. for example i want to to make a program that run
other file call try.exe and save all the stdout into a file
To start with you need an OS that can run .exe files. This is
off-topic here, where we deal with the portable standard C
language. Try a newsgroup that deals with your system.

--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfoc us.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

May 28 '07 #4
Chief wrote:
Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it

for example i want to to make a program that run other file call
try.exe and save all the stdout into a file
thanx
to run programs use the "system" function.

system("c:\\myd ir\\myprogram.e xe");
or use one of the several "exec*" functions.
May 28 '07 #5
Chief wrote:
Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it

for example i want to to make a program that run other file call
try.exe and save all the stdout into a file
This is c.l.c FAQ, see Q 19.27 and Q 19.30.

--
Tor <torust [at] online [dot] no>
May 28 '07 #6
On May 28, 2:56 pm, Chief <blons...@gmail .comwrote:
Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it

for example i want to to make a program that run other file call
try.exe and save all the stdout into a file

thanx
For command line program, Mr Carramba is right. But within a program,
try these stuffs

Your program, a parent process, forks a child and exec's the second
try.exe (with arguments). Close stdout for child and redirect its
output to a file using dup systemcall and pipes.

For more about fork() - see http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC3

Here is a basic code that resembles your problem, though not same
This program pipes the o/p of 1 command to i/p of another
=============== =============== =============== =============== =============== =====
#include<stdio. h>
main(){
int pfd[2] ;

if(pipe(pfd) < 0){
fprintf(stderr, "Cannot Create pipe\n");
exit(0);
}
switch(fork()){
case -1:
fprintf(stderr, "cannot create child\n");
exit(-1);
case 0:
if(dup2(pfd[1] , 1 ) < 0){
fprintf(stderr, "Cannot dup\n");
exit(0);
}
close(0) ;
close (pfd[1]);
close (pfd[0]);
execlp("ls", "ls", "-l", NULL) ;
fprintf(stderr, "Cannot exec 1\n");
default :
break ;
}
switch(fork()){
case -1:
fprintf(stderr, "Cannot fork 2\n");
exit(0);
case 0:
if(dup2(pfd[0] , 0) < 0) {
fprintf(stderr, "Cannot dup 2");
exit(0);
}
close(pfd[0]);
close(pfd[1]);
execl("/usr/bin/wc", "wc", NULL);
fprintf(stderr, "Cannot exec 2\n");
default:
break ;
}
wait ((int *)0) ;
}
=============== =============== =============== =============== =============== =============== ===
Bye
Guru Jois

May 28 '07 #7
Guru Jois wrote:
On May 28, 2:56 pm, Chief <blons...@gmail .comwrote:
>Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it
<snip>
For command line program, Mr Carramba is right. But within a program,
try these stuffs

Your program, a parent process, forks a child and exec's the second
<snip>

Since most ".exe program"s are run on Windows and Windows does not have
fork or (last I looked) exec this advice is not likely to be too useful.

Doing anything beyond a call to system (and the OP probably wants more
than that) requires using system specific extensions and the best place
to ask about those is in system specific groups. so I suggest the OP ask
in a group dedicated to his implementation.
--
Flash Gordon
May 28 '07 #8
On May 28, 8:07 pm, Flash Gordon <s...@flash-gordon.me.ukwro te:
Guru Jois wrote:
On May 28, 2:56 pm, Chief <blons...@gmail .comwrote:
Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it

<snip>
For command line program, Mr Carramba is right. But within a program,
try these stuffs
Your program, a parent process, forks a child and exec's the second

<snip>

Since most ".exe program"s are run on Windows and Windows does not have
fork or (last I looked) exec this advice is not likely to be too useful.

Doing anything beyond a call to system (and the OP probably wants more
than that) requires using system specific extensions and the best place
to ask about those is in system specific groups. so I suggest the OP ask
in a group dedicated to his implementation.
--
Flash Gordon
Ok, I agree to this. I got it now....bit later

Bye
Guru Jois

May 28 '07 #9

"Chief" <bl******@gmail .comwrote:
Hello i would like to know
which syntax do i have to use in order to make a program run other
*.exe program and also how to put inputs in it

for example i want to to make a program that run other file call
try.exe and save all the stdout into a file
Just write the whole command-line as a string, and feed the string to
the "system" function, like so:

#include <stdlib.h>
...
system("C:\\asd f\\try.exe 37 62 D:\\qwer\\outpu t_file.txt");

That would look for a program called try.exe in folder C:\asdf,
feed it "37 62" as command-line arguments, and redirect the
output to file output_file.txt in folder D:\qwer.

That syntax should work for DOS or Windows. For Linux or Unix,
use / instead of \\. For other OSs, read the manual.

(In practice, with most compilers, you can use / instead of \\
even with DOS or Windows; the compiler translates. Look up
"system" in your compiler's manual.)
--
Cheers,
Robbie Hatley
East Tustin, CA, USA
lonewolf aatt well dott com
triple-dubya dott tustinfreezone dott org
May 28 '07 #10

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

Similar topics

1
1882
by: bscofield | last post by:
Hi, I'm a db app. developer and I am re-writing some helps in javascript & HTML. The Javascript is for form flow and design and HTML just to display the helps. I use a seperate app. development platform and need to communicate between it and Javascript. Does javascript write to memory variables that are accessible to other programs? I know the "other programs" part is up to me but does JS write to something that is used to communicate to...
12
3448
by: jrefactors | last post by:
If the C programs have UNIX system calls such as fork(), alarm(), etc.., we should call it UNIX programs, not traditional C programs? We couldn't compile the programs with system calls using VC++ compiler. I need to compile it under UNIX platform. correct? any other alternatives?? Please advise. Thanks!!
7
1734
by: Coca | last post by:
Hello, all I am working on a project that needs to convert OS/2 C60 programs into MS windows programs. And I found it difficult to find useful information. Could somebody kindly help me ? any tips?web sites? 1. How can I convert OS/2 C60 programs into MS windows programs? 2.Where can I find information on OS/2 C60 ?any web
2
1346
by: Jim Smith | last post by:
Hello everyone, I work for a large company that supports many websites. My manager wants everything rewritten in ASP.Net. He has given me the task to find out the best method for putting programs into production. I know that there is a "bin" issue with the different projects that are created. I don't have a clue on how to organize everything so he can move programs into production easily. Any help would be greatly appreciated!
10
5748
by: www.hitechskill.com | last post by:
HiTechSkill.Com offers free information, tests, and sample interview questions that will help to improve your information technology skills. http://www.hitechskill.com
55
12828
by: Steve | last post by:
I have to develop several large and complex C++ hardware test programs that should work under DOS, most likely with 32-bit DOS extender. Development workstation OS would be Microsoft XP. Quite some time ago I worked in DOS, with Borland BC++ 4.1. I do not have it any more. Which compiler would you recommend me now? Which ones support serious DOS program development? Criterion should be number of available free library modules (graphic menu...
10
2694
by: sasquatch | last post by:
X-No-Archive: Are there any good books that provide tips about how to understand and "play with" large C++ programs? It seems like a very important skill, and yet its hardly taught in the universities. Basic programming skills and knowledge of language constructs don't seem enough for understanding larger programs.
4
5541
Cyberdyne
by: Cyberdyne | last post by:
In your All Programs Menu, some of your programs are in alphabetical order and others are not. This makes it very difficult to seek out a program that may be hidden in a maze of program folders and files. The solution is simple: have the computer re-sort the menu. When you install new programs, Windows XP tacks them to the end of your All Programs menu, rather than inserting them in the correct alphabetical order. So every so often you have...
1
1874
by: wstach | last post by:
Hi, I'm using Windows XP, IIS & ASP to develop a web service that executes several programs (command line .exe files) on a server, shows next webpage with info on progress in execution, and presents the results page. Basically, on the first webpage (html) user chooses which programs are to be executed, and then an asp script runs the programs on the server. The problem is that I don't know how to run these programs in
0
9961
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Programs dealing with autoruns Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list programs that help me to view/modify the autoruns on my Windows PC? Ans: Other than Sysinternals Autoruns, there are only a few programs which are good enough to be used when dealing with autoruns. For more information about Sysinternals Autoruns, read Que-7 in Windows Autorun FAQs: Description....
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9388
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6800
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3319
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.