Results 1 to 2 of 2

Thread: QProcess plink.exe - how to process->write

  1. #1
    Join Date
    Apr 2010
    Posts
    21
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QProcess plink.exe - how to process->write

    Hello, I need a little push up. I need to use plink.exe(putty) to quickly implement ssh connection, but I do not know how can I write data right to process.
    Before writing is everything OK - I logged in succesfully. Thank you for any help

    Qt Code:
    1. QProcess *process;
    2. process = new QProcess ( this );
    3. process->setProcessChannelMode(QProcess::SeparateChannels);
    4. process->setReadChannel(QProcess::StandardOutput);
    5.  
    6. process->start("plink.exe -ssh -pw test test@192.168.1.187", QIODevice::ReadWrite);
    7.  
    8. if (!process->waitForStarted(20000)) {
    9. process->close();
    10. return;
    11. }
    12.  
    13.  
    14. //hold until process has responded
    15. if (!process->waitForReadyRead(20000)) {
    16. process->close();
    17. return;
    18. }
    19.  
    20. // user logged, send command
    21.  
    22. process->write("quit\n");
    23. process->closeWriteChannel();
    24.  
    25. if (!process->waitForFinished()) {
    26. qDebug() << "err";
    27. process->close();
    28. return;
    29. }
    30.  
    31. qDebug() << process->readAll().data();
    32. process->close();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Apr 2010
    Posts
    21
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess plink.exe - how to process->write

    Solved by added file in calling process with plink

Similar Threads

  1. Replies: 0
    Last Post: 26th August 2010, 10:44
  2. QProcess, how to give focus to the new process on Mac
    By simlab in forum Qt Programming
    Replies: 3
    Last Post: 24th January 2010, 23:27
  3. Process Read/Write
    By QbelcorT in forum Newbie
    Replies: 0
    Last Post: 20th November 2008, 03:08
  4. QProcess, plink, mysql
    By tpf80 in forum Qt Programming
    Replies: 6
    Last Post: 10th October 2008, 02:28
  5. Connecting with QProcess to an already running process
    By high_flyer in forum Qt Programming
    Replies: 7
    Last Post: 26th November 2007, 10:31

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.