#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    7
    Rep Power
    0

    UNIX command line calls


    I have a question on calling a UNIX command from a C++ program. Suppose I want to use the command

    " finger >temp.txt "

    from a UNIX command line. How would I do this from a C++ program? I believe its system but I am not sure about the syntax. Can anybody help me out??? Thanks alot
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    system("finger > temp.txt");

    Woo hoo, I believe that's my 1000th post here :)
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    7
    Rep Power
    0
    Thats what I thought it was but when I tried my code on gcc compilier i get the following errors:

    test.cpp: In function `int main(...)':
    test.cpp:4: implicit declaration of function `int system(...)'

    My code is this

    #include<iostream>
    void main()
    {
    system("finger > temp.txt");
    }
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,648
    Rep Power
    4248
    Add this line near the #include <iostream>
    Code:
    #include <cstdlib>
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    7
    Rep Power
    0
    AHHHHhh...so simple...thanks!!!!!

IMN logo majestic logo threadwatch logo seochat tools logo