Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, How to pass some parameters f

Status
Not open for further replies.

DoubleH

Programmer
Dec 17, 2001
58
GB
Hi,
How to pass some parameters from a C/C++ program to a shell script? It will be helpful if You could give me a sample of it.

Thanks in advance.
Thanks & Regards,
DoubleH
 
If you don't need the output of the program, you could use the system function. It's only argument is the command to execute and it returns the commands exit status.
For example, to execute ~/.bashrc
Code:
if (system("/bin/bash ~/.bashrc") == 0)
{
    printf("Command succeeded.\n");
}
else
{
    printf("Command failed.\n");
}
If you want to get the output of the program, you could use popen which opens a pipe to the specified command. Look it up in the man pages. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top