LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-15-2004, 08:39 AM   #1
supermichou_fr
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
net="eth0";
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
mfeat
Member
 
Registered: Aug 2003
Location: Akron, OH
Distribution: Fedora Core 3
Posts: 185

Rep: Reputation: 30
char cmd[100];
net="eth0";
sprintf(cmd, ""ifconfig %s", net)
system (cmd);
 
Old 03-15-2004, 10:18 AM   #3
hiteshmaisheri
Member
 
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
supermichou_fr
LQ Newbie
 
Registered: Mar 2004
Posts: 2

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

Rep: Reputation: Disabled
thanks
 
  


Reply


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


All times are GMT -5. The time now is 04:27 PM.

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