Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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 😟

MacBook Air, OS X El Capitan (10.11.1)

Posted on Feb 18, 2016 2:54 PM

Reply
Question marked as Best reply

Posted on Feb 21, 2016 6:04 PM

At first glance, it sounds to me like you need to brush up on your ssh.


# ssh some.host python /home/exe/ai.py

will ssh to the specified host, and run the command 'python /home/exe/ai.py'.


To run this via AppleScript, put it in a do shell script command:


do shell script "ssh some.host python /home/exe/ai.py"

2 replies
Question marked as Best reply

Feb 21, 2016 6:04 PM in response to exe paul

At first glance, it sounds to me like you need to brush up on your ssh.


# ssh some.host python /home/exe/ai.py

will ssh to the specified host, and run the command 'python /home/exe/ai.py'.


To run this via AppleScript, put it in a do shell script command:


do shell script "ssh some.host python /home/exe/ai.py"

Feb 21, 2016 6:04 PM in response to exe paul

If you simply want to invoke the specified Python on the remote system, then the following shell script (in a filename with a .sh or .command file type to make it execute on double click), with a chmod +x to make the bash shell script executable, should be pretty close:

#!/usr/bin/env bash

ssh user@example.com /path/to/command


Reversing the software stack from your current AppleScript-calling-bash approach, bash can use osascript to access the GUI, too; there are examples of this around.


If you've not encountered it already, Apple has a Shell Scripting Primer.

open ssh server files automatically with apple script

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.