lib/src/BoxTools/VisItPythonConnection.cpp
// ****************************************************************************
//  Method:  SendCommand
//
//  Purpose:
//    Send a command, then send a newline, then wait for the prompt to return.
//
//  Programmer:  Jeremy Meredith
//  Creation:    June 12, 2007
//
// ****************************************************************************
SendCommand
Purpose:
Send a command, then send a newline, then wait for the prompt to return.

Jeremy Meredith
Creation:    June 12, 2007
SendCommand Purpose : Send a command then send a newline then wait for the prompt to return . Jeremy Meredith Creation : June 12 2007
bool VisItPythonConnection::SendCommand(const char *buff)
{
    if (visitpid == -1)
    {
        error = "send command failed; CLI was not launched";
        return false;
    }
    struct timeval zerotimeout =
    {
      0,0
    };
    fd_set errorset;
    FD_ZERO(&errorset);
    FD_SET(to_cli, &errorset);
    if (select(to_cli+1,&errorset, NULL, NULL, &zerotimeout))
    {
        error = "data sent from CLI on wrong pipe; write error assumed";
        return false;
    }
    if (!WriteString(buff))
        return false;
    if (!WriteString("\n"))
        return false;
    if (!WaitForPrompt())
        return false;
    return true;
}
bool VisItPythonConnection :: SendCommand ( const char * buff ) { if ( visitpid == -1 ) { error = " " ; return false ; } struct timeval zerotimeout = { 0 , 0 } ; fd_set errorset ; FD_ZERO ( & errorset ) ; FD_SET ( to_cli , & errorset ) ; if ( select ( to_cli + 1 , & errorset , NULL , NULL , & zerotimeout ) ) { error = " " ; return false ; } if ( ! WriteString ( buff ) ) return false ; if ( ! WriteString ( " \n " ) ) return false ; if ( ! WaitForPrompt ( ) ) return false ; return true ; }
Method:  SendCommand
Purpose:
Send a command, then send a newline, then wait for the prompt to return.
Method : SendCommand Purpose : Send a command then send a newline then wait for the prompt to return .
// Make sure we've opened visit's CLI before trying this // Stupid signal.  We can detect errors ourselves, thankyouverymuch. // signal(SIGPIPE, SIG_IGN); // Alas, GDB interferes with signals, so trying to SIG_IGN this isn't // a good idea.  Instead, we assume the CLI is behaving normally and // we should never have anything to read on the to_cli socket. // Write the string // Write a newline // Wait for the prompt to return // Enable for debugging //fprintf(stderr, "Sent command %s\n",buff); // Success!