Thread: Communicating with external programs

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    83

    Communicating with external programs

    My program needs to communicate with another program in Python. What I need my program to do is... execute
    #login (username) (password)
    in the shell, and see if the output login gives is "Success!" or "Failure.".
    I think the system() function might help, but I don't know what it is or how to use it. What would you do?

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    108
    I think I follow what your asking, try the example, and then apply it to your problem. Maybe it's what your looking for.

    Code:
    #include <process.h>
    
    int main (void)
    {
        _spawnl (_P_WAIT, "/windows/notepad.exe", "notepad", "ThisSourceFile.c", 0);
        return 0;
    }
    Last edited by DarkStar; 04-27-2004 at 05:58 PM.

  3. #3
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Look into the popen( ) command.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  4. #4
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    I don't know if Python can handle signals, but if Python it can look into signals.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  5. #5
    /*enjoy*/
    Join Date
    Apr 2004
    Posts
    159
    Code:
     ORIGINALLY POSTED BY DARKSTAR 
    include <process.h>
    
    int main (void)
    {
        _spawnl (_P_WAIT, "/windows/notepad.exe", "notepad", "ThisSourceFile.c", 0);
        return 0;
    }
    I COMPILE YOUR CODE AND I HAVE TOW ERROR
    FIRST
    Code:
    fuction _spawlnl should have a prototype
    second
    Code:
    udefined symbol _p_WAIT
    can you explain this darkstar ????

  6. #6
    Welcome to the real world
    Join Date
    Feb 2004
    Posts
    50
    Enjoy, did you even compile this code? The errors you gave us do not even resemble the source code you posted.


    You need to look into process.h. _spawnl is defined as spawnl for me and _P_WAIT is defined as P_WAIT in the header file. I use djgpp and winxp, and this is what is defined in the process.h file:


    Here is my code that will work for DJGPP and winxp:
    Code:
    #include <process.h>
    
    int main (void)
    {
        spawnl (P_WAIT, "/windows/notepad.exe", "notepad", "ThisSourceFile.c", 0);
        return 0;
    }
    This simply executes notepad.exe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. Including lib in a lib
    By bibiteinfo in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 02:28 PM
  4. debug to release modes
    By DavidP in forum Game Programming
    Replies: 5
    Last Post: 03-20-2003, 03:01 PM
  5. Unresolved external symbols in OGL
    By Shadow12345 in forum Game Programming
    Replies: 4
    Last Post: 08-04-2002, 09:46 PM