Monday, February 7, 2011

C++ inside a Shell Script !!!

From my previous post I told you that I was learning Shell Programming. Once I got familiar with Shell Scripting, I got to know that the commands we type in the terminal can also be executed from shell scripts if we include the command within the grave operators.
eg: In Terminal = date
     In shell script = echo `date`

Suddenly I got an idea. If I write a C++ program and give the run command from a shell script, when I execute the shell script, the C++ program also should work.

I took a new file (a.cpp) and wrote the C++ program in that. 
eg:  vi  a.cpp

 I compiled the C++ program and executed it.

 
Then I wrote my shell script in myscript.sh file
eg:  vi  myscript.sh
I gave the full path of my C++ program so that the location where the Shell Script is saved does not matter when executing the C++ program.

 
It really worked !!!

P.S - At the moment I have completed 120 pages from that ebook

-Tharindu Edirisinghe-
-SLIIT 10'-

0 comments:

Post a Comment