UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » hw to excute command_string in sprintf

#1 2007-09-03 08:45 AM

santoshkumar
Member
Registered: 2007-08-21
Posts: 53

Re: hw to excute command_string in sprintf

im wondering hw i can make string formed to work in system command
case :
have formed comand string
sprintf(command_string," iptables ...");
to use
system("command_string");

how to achieve it?

thanku 4 help

Offline

#2 2007-09-03 11:28 AM

santoshkumar
Member
Registered: 2007-08-21
Posts: 53

Re: hw to excute command_string in sprintf

wrks
ex,

#include <stdio.h>
#include <stdlib.h>

main() {
char *str = "echo san";

system(str);
}

Offline

#3 2007-09-03 05:11 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: hw to excute command_string in sprintf

Um, did you just answer your own question?  Or, is there still something you're
trying to ask?  Because, if so, I have no idea what it is, exactly...

Offline

  • Index
  • » C
  • » hw to excute command_string in sprintf

Board footer

Powered by FluxBB