Results 1 to 4 of 4

Thread: QProcess to interact with a command-line based windows executable on linux

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2013
    Posts
    2
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QProcess to interact with a command-line based windows executable on linux

    Hi!

    I'm having a lot of trouble getting my QProcess to interact with an executable file. Just a bit of background, I have a QT application in Linux and I'm trying to import some data (electromagnetic tracker) from an existing Windows executable to use in my linux code. This windows executable is able to stream the data I need after first connecting to the tracking device over the network. I'm using wine to run the executable in linux, and it works great with the command line. What I want though, is to have my QT application (a simulation with a haptic device) to automatically run the executable, input the commands needed to start data acquisition (i.e. connect to the correct IP address for the device and enter a few specific commands like numbers and enter key presses).

    I am able to get xterm (or gnome-terminal) to run my windows executable with the following commands:
    QObject *parent;
    ....
    QString arguments;
    arguments <<"-e" << "wine ./{path to exe}/{name}.exe"; // stuff in {} is specific to my program. the path and name is correct.
    QProcess *myProcess = new QProcess(parent); // this might be unnecessarily complicated with the parent.
    myProcess->start("xterm",arguments); // here the windows executable command line interface shows up on the new terminal.
    myProcess->write("1\n"); // THIS AND BELOW DON'T WORK. using the wait until complete function doesn't help
    myProcess->write(" {dev IP address} 0/n");
    myProcess->write("19/n");
    myProcess->write("20000/n");
    <here I'm expecting to see data streaming on the terminal>
    -------

    When the terminal window opens, I am actually able to manually enter the necessary commands, and the program works fine. However, I can't figure out how to input the commands automatically with my QT code. After extensive searching online, I thought it might have something to do with not starting bash so I added that to my argument list, but with that addition, it looked like my executable didn't start and neither did the new terminal. Also, hopefully this bug isn't due to wine - I can't avoid that! Any help would be greatly appreciated!!

    Thanks!
    Ann

    PS - I still haven't tried to collect data from the terminal and plan to do so with myProcess->readAllStandardOutput() once I can actually get data to stream. If you forsee any issues with that, please let me know!
    Last edited by AnnM; 30th July 2013 at 04:29.

Similar Threads

  1. Execute window command line-by-line using QProcess
    By nhocjerry in forum Qt Programming
    Replies: 5
    Last Post: 30th July 2013, 12:21
  2. Replies: 7
    Last Post: 15th November 2010, 09:00
  3. Replies: 0
    Last Post: 28th June 2010, 01:29
  4. Replies: 3
    Last Post: 23rd February 2010, 04:33
  5. QProcess and the command line
    By auba in forum Qt Programming
    Replies: 17
    Last Post: 27th May 2009, 10:39

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.