2 Replies Latest reply: Oct 11, 2013 11:56 AM by rccharles
Connorm_19 Level 1 Level 1 (0 points)

I am living in university residence and in order to log in to the internet provided you must input a short script into terminal. What I want to do is to be able to start a workflow (on my command) to open terminal and input two lines of script.

 

So, what I want to do is to start a workflow and automatically...

1. Open terminal

2. Input username (one line Ex. "ssh xxxxxx@10.0.0.1"), click enter

3. Pause

4. Input password (Ex. "xxxxxxxxxxxx"), click enter

5. Minimize terminal (not close)

 

Can anyone help me please?


Macbook Pro 15 inch, Mac OS X (10.6.4), Ipod Touch 32GB
  • rccharles Level 5 Level 5 (6,130 points)

    Well, did it through applescript

     

     

    tell application "Terminal"
        activate
    end tell
    
    delay 3 -- seconds
    
    tell application "System Events"
        keystroke "ssh mac@192.168.0.10"
        keystroke return
        delay 3
        keystroke "password"
        -- if you went to press return after typing the password
        keystroke return
        delay 3
        keystroke "h" using command down
    end tell
    

     

     

     

     

    I posted an Applescript program. 

     

    Here is the program:

     

     

    (* 
    
    https://discussions.apple.com/thread/3033221?tstart=30
    
    Required:
    
    
    Turn on accessability GUI in system preferences.
    
    Optional:
    --------
    Full Key Codes
    http://www.versiontracker.com/dyn/moreinfo/macosx/21215
    
    
    youpi or iKey
       youpi and iKey are keystroke remapping programs.
       youpi, the free version, works fairly well for me in Mac OS 10.4 although not officially supported. 
    http://www.versiontracker.com/dyn/moreinfo/macosx/11485&vid=75326
       iKey is the paid version
    http://www.scriptsoftware.com/ikey/
    
    *)
    
    on run
        -- Write a message into the event log.
        -- To see, run this applescript in Sript Editor. Click on Event Log tab at bottom of screen.
        -- Click run.
        log "  --- Starting on " & ((current date) as string) & " --- "
    
        set fromApp to "Safari"
        set toApp to "TextEdit"
    
        --- We have arrived.
    
    
        say "we are beginning now."
    
        -- Start your application
        tell application fromApp
            activate
        end tell
    
        delay 1
    
        say "copy data to clipboard"
    
        tell application "System Events"
            tell process fromApp
    
    
                keystroke "c" using command down
                delay 2
    
            end tell
        end tell
    
    
        -- Start your application
        tell application toApp
            activate
        end tell
    
        delay 5
        tell application "System Events"
            tell process fromApp
                --  open file menu
                keystroke return
                keystroke return
                keystroke return
    
                keystroke "v" using command down
    
            end tell
        end tell
    
        say "good news, We are done."
    
    end run
    

     

    The first thing that you need to do is to make the text into an AppleScript program.

     

    Start the AppleScript Editor

    /Applications/AppleScript/Script Editor.app

    In Snow Leopard it's at: /Applications/Utilities/AppleScript Editor

     

    Copy the script text to the Applescript editor.

     

    Save the text to a file as an application and do not check any of the boxes below.

    http://farm4.static.flickr.com/3544/3390737677_645a847e28.jpg?v=0

    If you want access to the script from your Script Menu, move the script (the saved script application file) to your

    ~/Library/Scripts folder. You can also drag it to your Dock or make an alias for it on the Desktop.<br><br>

     

    To debug, run the script within the Applescript Editor. Click on the event log tab at the bottom of the window. Click  on the run icon.  The results from the log statement will be shown at the bottom of the screen.

    http://farm5.static.flickr.com/4029/4690586217_1f57b5a2f5.jpg

     

    ---------------

  • rccharles Level 5 Level 5 (6,130 points)

    Here is my standard post for creating an applescript app.

     

     

     

     

     

    Here is how to create an Applescript Application. 

     

    Here is the program:

     

     

    (* 
    
    https://discussions.apple.com/thread/3033221?tstart=30
    
    Required:
    
    
    Turn on accessability GUI in system preferences.
    
    Optional:
    --------
    Full Key Codes
    http://www.versiontracker.com/dyn/moreinfo/macosx/21215
    
    
    youpi or iKey
       youpi and iKey are keystroke remapping programs.
       youpi, the free version, works fairly well for me in Mac OS 10.4 although not officially supported. 
    http://www.versiontracker.com/dyn/moreinfo/macosx/11485&vid=75326
       iKey is the paid version
    http://www.scriptsoftware.com/ikey/
    
    *)
    
    on run
        -- Write a message into the event log.
        -- To see, run this applescript in Sript Editor. Click on Event Log tab at bottom of screen.
        -- Click run.
        log "  --- Starting on " & ((current date) as string) & " --- "
    
        set fromApp to "Safari"
        set toApp to "TextEdit"
    
        --- We have arrived.
    
    
        say "we are beginning now."
    
        -- Start your application
        tell application fromApp
            activate
        end tell
    
        delay 1
    
        say "copy data to clipboard"
    
        tell application "System Events"
            tell process fromApp
    
    
                keystroke "c" using command down
                delay 2
    
            end tell
        end tell
    
    
        -- Start your application
        tell application toApp
            activate
        end tell
    
        delay 5
        tell application "System Events"
            tell process fromApp
                --  open file menu
                keystroke return
                keystroke return
                keystroke return
    
                keystroke "v" using command down
    
            end tell
        end tell
    
        say "good news, We are done."
    
    end run
    

     

    The first thing that you need to do is to make the text into an AppleScript program.

     

    Start the AppleScript Editor

    /Applications/AppleScript/Script Editor.app

    In Snow Leopard it's at: /Applications/Utilities/AppleScript Editor

     

    Copy the script text to the Applescript editor.

     

    Save the text to a file as an application and do not check any of the boxes below.

     

     

    as.jpg

     

    If you want access to the script from your Script Menu, move the script (the saved script application file) to your

    ~/Library/Scripts folder. You can also drag it to your Dock or make an alias for it on the Desktop.<br><br>

     

    To debug, run the script within the Applescript Editor. Click on the event log tab at the bottom of the window. Click  on the run icon.  The results from the log statement will be shown at the bottom of the screen.

     

     

    asrun.jpg