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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I call a unix shell script from C?

Status
Not open for further replies.

SuaveRick

Programmer
Apr 12, 2004
142
CA
I need to call a shell script on my unix box from within C and I need to pass one variable. This is what I have:

system("/home/dtuser/Grant/SMR/Script/vMirror3.sh %s", privCode);

the privCode is what's causing a problem, when I build I get an unknown argument so that's obviously not the way to pass a variable.

Thoughts?
 
Code:
char cmd[1000];
sprintf(cmd,"/home/dtuser/Grant/SMR/Script/vMirror3.sh %s", privCode);
system( cmd );

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top