Search code examples
cclient-serverexecnano

Client/server: running "nano editor" command from client


I have a client/ server program written i c language, a client can send and receive .txt documents to the server, i wish to Open the file received to visualize it with command nano For example, inside the running process:

Something like this: Exec( nano, "file-to-Open.txt") but i dont know how to do do this), can You help me?

Sorry For my english Thank's a lot


Solution

  • Try this:

    execlp("nano", "nano", "file.txt", NULL);
    

    The nano editor must be in your path, the file.txt must be in the current directory of the running client process, and most importantly, whatever display the editor is going to display on must be accessible, be it the terminal from where the client is run or the appropriate X-Windows display.