Computing.Net > Forums > Unix > unix commands calling from c program

unix commands calling from c program

Reply to Message Icon

Original Message
Name: Balaji
Date: June 20, 2002 at 14:32:59 Pacific
Subject: unix commands calling from c program
Comment:

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 .Thank you,
bye
-balaji


Report Offensive Message For Removal


Response Number 1
Name: cup
Date: June 22, 2002 at 11:35:48 Pacific
Subject: unix commands calling from c program
Reply: (edit)

Concatenate your strings separated by spaces.

char cmd[128];
int i;
cmd[0] = '\0';
for (i = 1; i < argc; i++)
{
strcat(cmd, argv[i]);
strcat(cmd, " ");
}

Call the command using system

system (cmd);



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: unix commands calling from c program

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software