Making an automator service for screen sharing

Discussion in 'Mac Programming' started by Ruahrc, Apr 28, 2010.

  1. Ruahrc macrumors 65816

    Joined:
    Jun 9, 2009
    #1
    I have a question about making an automator workflow, I hope this is the right area for that?

    I have a computer at work (iMac) which I would like to be able to vnc into using the built in screen sharing. I have enabled the "remote login" service on the work iMac to create a secure ssh tunnel into it that the VNC will use.

    As it is, I can do it manually by opening the terminal, and using the following command:

    ssh -N (username)@(ip_address) -L 5901/(ip_address)/5900

    That forwards port 5901 locally to 5900 on the ssh connection. I configured the iMac to accept key-based authentication so I don't have to enter in the password in order to initiate the ssh connection. I then press Command-K in the finder and type in:

    vnc://localhost:5901

    which looks for vnc on local port 5901 (really forwarded to ip_address:5900) and opens the screen sharing. (I do have to authenticate here with a username/password, which is okay I want it that way)

    When I'm done I close screen sharing, and quit the active terminal window, which closes the ssh connection.

    I want to get it so that I can automate the creation of the ssh tunnel (partway there after configuring key-based authentication), so that I can just enable it and then start screen sharing. Even better would be to launch the screen sharing right from the workflow, leaving me with just having to select that service from the menu, then being presented with the username/password box to authenticate for screen sharing. I thought I would be able to do this because you can execute terminal commands using the "run shell script" function in automator but I'm having a little trouble.

    I can get the shell script to run, but as it does not really "finish", the automator workflow never proceeds past this point. So I seemingly can't launch the connection, then have it start up a screen sharing (really just an attempt to connect to a specific server)?

    I tried a workaround where I just put the shell script action into the automator workflow, which works in the sense that when I select that service it runs, makes the ssh connection, and I get the spinning gear in my systray. It spins perpetually because the shell script never really "finishes". I can then manually start up SS and it works, but when it comes time to close it down I manually exit SS, and then go up to the spinning gear and tell it to stop. The spinning gear goes away but it seems like the ssh connection does not actually close down because there is still an ssh process running (seen in activity monitor) and subsequent attempts to connect to the iMac using SS still work.

    Any way I can get it to work the way I want it? Hopefully I have included enough details here, if not let me know I will try to explain it better.

    Ruahrc
     
  2. squirrel77 macrumors member

    squirrel77

    Joined:
    Mar 17, 2006
    Location:
    Barcelona ES
    #2
    bump

    I've been watching this, was going to have a go at figuring this out myself but haven't had a chance yet.
    Has the OP made any progress in the meanwhile? :confused:
     

Share This Page