Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-15-2004, 08:39 AM   #1
LQ Newbie
Registered: Mar 2004
Posts: 2

Rep: Reputation: 0
Question C program code to execute linux-command

First Please excuse me for my english, i'm french.

i'm a newbie in c programation
I write a little C program code with the command system("linux-command");
and now i want to execute a command with a variable like the command printf

ex : printf("hello %s",name);
where name is a variable

i try for example
system ("ifconfig %s", net);
but system don't accept more than 1 argument

is some one can help me please?
Old 03-15-2004, 09:43 AM   #2
Registered: Aug 2003
Location: Akron, OH
Distribution: Fedora Core 3
Posts: 185

Rep: Reputation: 30
char cmd[100];
sprintf(cmd, ""ifconfig %s", net)
system (cmd);
Old 03-15-2004, 10:18 AM   #3
Registered: Nov 2003
Location: Kerala, India
Distribution: Red Hat, Knoppix, Mandrake, FreeBSD
Posts: 231

Rep: Reputation: 30
thanks for the information....
Old 03-15-2004, 10:20 AM   #4
LQ Newbie
Registered: Mar 2004
Posts: 2

Original Poster
Rep: Reputation: 0
thank you
Old 08-01-2012, 08:25 AM   #5
LQ Newbie
Registered: Aug 2012
Posts: 1

Rep: Reputation: Disabled


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
execute shell command inside of c code? khucinx Programming 6 10-26-2010 09:30 PM
Execute a linux command using a java program tvalenzuela Programming 2 10-07-2005 11:59 AM
execute command from c code alaios Programming 3 06-06-2005 05:26 AM
C program code to run a Linux command line Linh Programming 10 06-11-2003 01:59 PM
C program code calling a Linux system command Linh Programming 1 06-05-2003 01:44 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:04 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration