473,394 Members | 1,841 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,394 software developers and data experts.

Make C++ execute a UNIX command

BenTheMan
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 3296
Silent1Mezzo
208 100+
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
It is as easy as follows:

char * filename = "myfile.tex";
char command[100];
sprintf(command,"pdflatex %s &",filename);
system(command);
Jun 25 '07 #3
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.net, 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
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...
9
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...
6
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...
7
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? ...
9
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...
2
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...
7
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
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...
12
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 =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
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,...
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
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...

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.