Search code examples
macossshterminalapplescriptautomator

open ssh server files automatically with apple script


Hello respected persons ,

i am trying to build a apple script which first open terminal login in ssh with details and after login it open a python script which is on ssh server automatically . i wanna do all of these tasks in a single apple script . i already tried to build automatic ssh login and i did . but i am facing problem how can i call a python script in ssh server automatically .

like i have a python file in ssh server /home/exe/ai.py

so i want each time i run that apple script it login in ssh and open ai.py automatically .

i am new in apple script please help :(

i am trying it fro 3 days but no luck please help me :(


Solution

  • You could use another do script:

    do script ("python /home/exe/ai.py") in currentTab
    

    Code:

    tell application "Terminal"
        set currentTab to do script ("ssh [email protected];")
        delay 5
        do script ("python /home/exe/ai.py") in currentTab
    end tell
    

    Note: this doesn't check for errors or handle exceptions, so you'll want to consider implementing something like that in order to deal with it if that's a concern.