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 IamaSherpa 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 parse a variable into a system call?!?

Status
Not open for further replies.

hotfoot

Technical User
Jul 15, 2001
5
AU
Scenario:
I want to parse a string variable into a system call..

I have a file with a range of ip's,
after reading in 1 ip I'd like to perform a call

to " nbtstat" (it identifies people on a network)

this works....
int main()
{

system("nbtstat -A xxx.xx.xxx.x");//If I entered
//the actual IP address

}
what I want to know is how to get my variable inside the call
so I can replace the x's with a var like a char* ..ie %s

does this make any sense?
Please help
 
#include <stdlib.h>
#include <string.h>

int main( void )
{
char sCommand[] = &quot;nbtstat -A &quot;;
char sIP[] = &quot;127.0.0.1&quot;;
char sCombine[25];

strcpy( sCombine,sCommand );
strcat( sCombine,sIP );

system( sCombine );

return 0;

} Mike L.G.
mlg400@blazemail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top