473,796 Members | 2,621 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Make C++ execute a UNIX command

BenTheMan
8 New Member
Ok---I was wondering...Is there any way to make C++ execute a UNIX command?

Like, I generate LaTeX files in my code, file.tex. Then I need to compile the .tex files with ``pdflatex file.tex'' which generates a pdf file, and makes life oh so beautiful.

Is there a way I can get C++ to tell UNIX to do this without me having to type it in every single time?
Jun 25 '07 #1
3 3318
Silent1Mezzo
208 New Member
Ok---I was wondering...Is there any way to make C++ execute a UNIX command?

Like, I generate LaTeX files in my code, file.tex. Then I need to compile the .tex files with ``pdflatex file.tex'' which generates a pdf file, and makes life oh so beautiful.

Is there a way I can get C++ to tell UNIX to do this without me having to type it in every single time?
Use the system() command.
Jun 25 '07 #2
seforo
60 New Member
It is as easy as follows:

char * filename = "myfile.tex ";
char command[100];
sprintf(command ,"pdflatex %s &",filename) ;
system(command) ;
Jun 25 '07 #3
BenTheMan
8 New Member
Bad ass. Thanks a lot.

BTW if you ever need help with your physics homework (assuming you have any) post in SciForums.com, or scienceforums.n et, and send me a PM.
Jun 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2148
by: Arne Lund | last post by:
I've to read variables out of a config-file, that is stored on a Linux-machine. When I connect to the server with puTTY, I can execute the config with: .. /usr/local/webspace/config then I can echo the contained variables: echo $var1 everything works fine. Now I want to execute the config by a php-script.
9
3034
by: Casanova | last post by:
Hello! How can I execute other exe files from within a executable file in GCC. In TurboC 3, the spawn command executes a file and returns command to the calling file. whereas in GCC, the exec command only starts the execution of the new file and does not return command to the calling file (the calling file is terminated on the start of execution of the called file)
6
16393
by: Joseph | last post by:
Hi, I am trying to develop a C# application that will run on Windows that will do the following * Select file name to process * FTP the file to a UNIX server * Process this file on UNIX using a program on UNIX "./pgmname -options Infilename > OutputFilename" * FTP the output of this program back to Windows * Process the resultant file and create output report file
7
2987
by: spec | last post by:
Hi all, I know nothing about Python. What I need to do is to get a Python script to execute a local shell script. I do not need any output. What would be th eeasiest way to accomplish this? Thanks!
9
78395
by: sohan | last post by:
Hi, I want to know how to connect and execute a db2 query from inside a UNIX shell script. Details: We have a unix shell script. We need to execute multiple db2 sql queries from this shell script and export the result to a file. Any code snippet on this will be helpful.
2
2381
by: wizardRahl | last post by:
Hello, I'm trying to install ArcInfo 9.2 (GIS software) on an Ultra 40 running Solaris 10 (x86). I am also extremely new to the unix environment. When I get to the correct path and try to run the install -load command from the command line, it brings back an error: "cannot execute" I've done some research and most of the problems I've seen have been occurring when users are confused about on which platform they are installing. The...
7
15766
by: sonet | last post by:
in perl we can execute command and get result(command line stdout) by $a=`cmdline parameter`; print $a; in c system('cmdline parameter'); but i can not get the result (command line stdout).
3
4362
by: JB | last post by:
I'm writing a small utility and I need to be able to connect to a unix server and execute a couple of commands. How would I go about doing this? It's fairly simple from the command prompt using telnet - but I have to wait for the thing to connect, enter username and password, wait again for it to authenticate, etc. Any tips?
12
2014
by: Atropo | last post by:
Hi all. Having several strings how do i combine them to construct a command; lets say to run the date command. string str = "14/10/08 19:06:09"; strDD = str.substr(0,2); strMM = str.substr(3,2); strAA = str.substr(6,2); strhh = str.substr(9,2);
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
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
10459
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
10237
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...
0
9055
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
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
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3735
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.