Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Call shell script from C++ program
Name: Dmitri Zaikine Date: June 21, 2001 at 06:49:48 Pacific
Comment:
Hi Is anybody knows how to execute shell script from C++ program Thanks a lot!
Name: Don Arnett Date: June 21, 2001 at 08:39:56 Pacific
Reply:
Look up the 'system()' function. I believe that it is fairly standard but am not sure.
Typically, you'd call it by passing a string as the only argument. The string would contain a command that you want to run.
system("erase c:/file.txt");
You may have to include the full path name of the command that you want to run.
0
Response Number 2
Name: NetPortal Date: June 21, 2001 at 20:21:29 Pacific
Reply:
The common way to do it is to call execl() function (and his analogs). You should run shell with the script you want to execute as a param. execl("/bin/sh shellscpt", "/bin/sh shellscpt", ....)
And try $man exec
0
Response Number 3
Name: NetPortal Date: June 22, 2001 at 20:04:03 Pacific
Reply:
Oy, Dima ya oshibsya, vizov delay tak:
execl("/bin/sh", "/bin/sh", "shellscpt")
0
Response Number 4
Name: Dmitri Zaikine Date: July 2, 2001 at 08:23:34 Pacific
Reply:
Thank you !
#include main() { if (fork() == 0) execl("/bin/sh","/home/oracle/temp/hello.sh","hello.sh", NULL); }
0
Response Number 5
Name: Alex Date: December 13, 2001 at 13:24:12 Pacific
Reply:
a zachem ata proverka?
if (fork() == 0)
0
Response Number 6
Name: Bruno Date: February 3, 2002 at 00:07:48 Pacific
Reply:
o comando if(fork() == 0) irah pegar o ID do processo corrente e comparar com o ID do processo criado pelo comando fork(), caso essa condicao se verifique, ira executar as instrucoes que estao contidas dentro do escopo de validade do if. (teremos dois processos, mas soh um irah executar - isso eh bastante utilizando para programacao em tempo real, onde se trabalha com escalonamento, prioridade, etc..)
0
Response Number 7
Name: jawad attari Date: February 9, 2002 at 18:25:19 Pacific
Reply:
hi,
does anybody how to use system() command for c++ under windows
Summary: Hi, i have a doubt. I want to call the multiple unix commands with options from c program using commandline prompt. for example : >program1 ls -l who date could you please solve this problem .Than...
Summary: Hi I have setup for CDE (common Desktop Environment)in Sun Unix. I was able to open browser from CDE. I wrote the following htm to run shell script test2.sh (which is in executable mode). I saved thi...