Terminal 'object'

Discussion in 'Mac Programming' started by DennisBlah, May 18, 2016.

  1. DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #1
    Is there anyone who knows how I can create a terminal 'object' inside an xCode application?
    I can execute an terminal command using NSTask, with /bin/sh as launchPath.

    This is working fine.. But.. I'd like to keep that 'session' open.
    For example... open a telnet connection, read the outcome, and afterwards depending on the action of a user I'd like to start sending commands to the 'session'

    I want to use it to open up a thirdparty CLI tool which opens a sort off 'session' like telnet, and need to put in several commands.

    To prevent user faults, I'd like to do this from xCode so the whole CLI is hidden
     
  2. chown33, May 18, 2016
    Last edited: May 18, 2016

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
  3. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #3
  4. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #4
    Hi Chown,

    again thanks for your reply tho. I been looking into it, but this is too much hassle
    I think I will work with an bash script using expect -> spawn -> expect (for response) -> send (commands)
     
  5. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #5
    If what you're trying to do is open a "telnet" connection and send/receive commands from a program, the real answer is to open a TCP connection to port 23 and then send and receive commands to that socket connection. There's no reason to get an NSTask or Shell or anything else involved.
     
  6. jasnw macrumors 6502

    Joined:
    Nov 15, 2013
    Location:
    Seattle Area (NOT! Microsoft)
    #6
    I agree with the previous poster. I've done something like this using python, not with a GUI interface however, and it was pretty simple to set up. I'd say pasting a GUI on it would be pretty easy (if you know how to do that, which I don't - I'm a CLI sort of bloke).
     

Share This Page