Can any one tell me how I can invorke/call a shell script in a c++ code so that I can I can invorke some shell commands using my c++ code. I am using scientific linux
5 2675
Can any one tell me how I can invorke/call a shell script in a c++ code so that I can I can invorke some shell commands using my c++ code. I am using scientific linux
you should be able to use the function system() in process.h, e.g. to run a file called script -
system("sh script"); // invoke a script
-
your parent process is suspended until the script is finished then it is resumed
Thanks, this is what I was looking for
Thanks, this is what I was looking for
you don't even need to use a script you can run shell programs directly -
system("ls -l"); // invoke ls
-
if you want the parent to run concurrently with the child process you can use -
int pid=spawnlp(P_NOWAIT,"ls","ls","-l",NULL);
-
see http://www.python.org/doc/2.3/lib/os-process.html
you don't even need to use a script you can run shell programs directly -
system("ls -l"); // invoke ls
-
if you want the parent to run concurrently with the child process you can use -
int pid=spawnlp(P_NOWAIT,"ls","ls","-l",NULL);
-
see http://www.python.org/doc/2.3/lib/os-process.html
I have a question on this,
I am able to run the shell script (getVar.sh) using the system command but I want the string returned by the shell script in my c++ code. I tried using popen but it crashes frequently. Is there anything else I can use?. Please help !!
regards
I have a question on this,
I am able to run the shell script (getVar.sh) using the system command but I want the string returned by the shell script in my c++ code. I tried using popen but it crashes frequently. Is there anything else I can use?. Please help !!
regards
you could write the output of the script to a file and then open and read that file, e.g. -
system("ls -l > x"); // invoke ls
-
the file listing will be in the file x
Sign in to post your reply or Sign up for a free account.
Similar topics
by: nobody |
last post by:
Hello all,
I've searched just about everything and although I can see that other
people are having problems, but theirs don't seem to relate, so in a
last ditch attempt, my posting!
Script...
|
by: Jakej |
last post by:
I've been using a javascript in an html file for a banner slider, and
it works as desired. But I'd like to use it on more than one page and
it would be great if I could transfer the code to a .js...
|
by: Russ |
last post by:
I've been trying to get my head around this for 3 days now and it
seems like everything I try does not work for one reason or another.
I built a test page using the TabStrip and MultiPage controls....
|
by: PJ |
last post by:
Greetings...
I have stumbled upon a small problem.
I use Ajax to retrieve part of a page I need to update. I update a DIV
element with the HTML contents I get from another page.
It works...
|
by: thisis |
last post by:
Hi All,
i have this.asp page:
<script type="text/vbscript">
Function myFunc(val1ok, val2ok)
' do something ok
myFunc = " return something ok"
End Function
</script>
|
by: rsteph |
last post by:
I have a script that shows the time and date. It's been working on my site for quite a while now. Suddenly it stops showing up, after getting my drop down menu to work.
If I put text between the...
|
by: Stefan Weber |
last post by:
Hi,
I'm trying to access the JavaScript code contained in a <scripttag
via its "text" attribute. This works well, if the code is embedded in
the HTML page. However, when the code is in an...
|
by: SOLAV |
last post by:
This is the only working way to completely hide your JavaScript code from the client just like PHP or ASP code.
Here we'll need the help of PHP. Here is the code:
index.php...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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,...
| |