Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Remote command shell
QtWS25 Last Chance

Remote command shell

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fomikadze
    wrote on last edited by
    #1

    Hi
    I decided to create some sort of my own remote command shell. I have implemented it on QTcpSocket and QTcpServer.
    Creation of client and server was the easiest part. But now I have problem with executing the command that I send from my clent to server. I know that QT does have QProcess class that executes what I send to it. I know how to get the output streams from part of programs that I run. In fact on this moment I have some tool (my program) that allows me to launch one command at a time. This is not the way the comman shell should work. When we use CMD in windows or Shell in Lunix we allways have an ability to launch a bunch of command, by giving the list of commands and waiting for the results.
    I'd like to know if there is any way to connect to the CMD or Shell process that I will create, send commands to it and the most necessary, redirect all output data to my client?

    P.S. I don't want to use batch or bash files. I'd like to use only Qt enviroment and Qt classes.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tucnak
      wrote on last edited by
      #2

      bq. P.S. I don’t want to use batch or bash files. I’d like to use only Qt enviroment and Qt classes.

      Why don't make temporary file in /tmp/qt/.... with .sh extension and run it with this code:
      @
      QProcess *proc = new QProcess(this);
      //.... code
      proc.start("sh", QStringList() << fileFullPath);
      @

      I think it will be the best solution to execute a list of commands.

      P.S. Use Qt instaed of QT (Quick Time), please. It has been written in rules that you see on the post page.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fomikadze
        wrote on last edited by
        #3

        tucnak, main idea to eliminate the need for making some changes in source code when I compile it for different OS.
        I thought about an ability to check the type of OS while program is running and depending on it's type use batch (for Windows) or bash (Linux) files. But I don't think that this is a good way to solve a problem. Maybe there're some other ways?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tucnak
          wrote on last edited by
          #4

          As far as I unsrstood, you need #ifdef statements. They allow to check current OS and execute special code for it. So, learn about it.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fomikadze
            wrote on last edited by
            #5

            Yep, also Qt has QSysInfo class that give me information about current OS.
            I'm not shure about this way to sort it out.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              twsimpson
              wrote on last edited by
              #6

              Don't change your servers behaviour at run-time, the OS is something that does not change from run to run. You use use #ifdef's and the Qt Q_OS_* macros to determine what behaviour your server-side should use at compile time instead.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved