Thread: Using Variables with th 'System' command

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    17

    Using Variables with th 'System' command

    Hi friends:

    I have a tiny problem.
    I want to graph some data i have stored in a file with the RRDtool program. This RRDTooll program works with shell commands:
    rrdtool create test.rrd \
    --start 920804400 \
    DS:speed:COUNTER:600:U:U RRA \

    etc, etc

    Now, I want to make a C program to graph these data. But i don't know how to add variables with the system command
    system("rrdtool create test.rrd --start %s ...",a);

    How can i do that in C. or How could i do that in a shell script????

    Please Help me!
    A Man can be whatever he wants to
    be

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Use a buffer to hold the string, something like:
    char buf[1024];
    Put you commands in there (maybe using strcpy(), sprintf() etc), then call system(buf);

    Alternatively, read the FAQ
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    17

    Talking

    Thanks a lot
    A Man can be whatever he wants to
    be

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. the system command
    By happyclown in forum C Programming
    Replies: 7
    Last Post: 01-02-2009, 07:14 AM
  2. Replies: 6
    Last Post: 07-21-2008, 03:10 AM
  3. Replies: 30
    Last Post: 09-12-2006, 07:06 PM
  4. using system command results in a program
    By finnepower in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2005, 08:58 AM
  5. System Calls && Variables
    By Okiesmokie in forum C++ Programming
    Replies: 6
    Last Post: 03-06-2002, 09:10 PM