run(command) on MAC

Asked by Stephan

Hi there,
I'm trying to build up an ssh connection via a python script(sftp.py) called by a sikuli-script.
This works actually fine on windows using the run command:

run("python /Users/user_name/Desktop/STF/sftp.py /Users/user_name/APP/Logs/leopard[CHR13xFF6]results.txt <email address hidden>:/data/user/test/leopard[CHR13xFF6]results.log -p password")

Am I missing something?
Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

I never got complex run commands working on Mac.

Finally I ended up using Jythons subprocess, which is much more flexible (after some experiments with os.popen).

And I always tried the command in the Terminal before baking it into a script: this gives some hints on needed apostrophes.

In some cases, it was easier to make a shell script, that could be called with "compact" parameters or without any parameters.

Revision history for this message
Stephan (kannelon) said :
#2

I already tried it on the terminal before coding it. And it worked.
I Had the same problem using run commands on windows and thought things couldn't get worse on mac ;-)
Anyway I gave a try with os.popen and got following error message:

python: posix_spawn: /System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python: No such file or directory

 ...I guess it has something to do with my last upgrade to python27, right?
How can I fix it?
Thanks

Revision history for this message
Best RaiMan (raimund-hocke) said :
#3

Upgraded to 2.7? How did you do that?

Somehow you have mixed things up: from command line you seem to use 2.7, but internally via launchctrl the 2.6 is still used, but some parts are missing now.

Might help to try to access Python 2.7 with it's absolute path?

On my Mac Lion Python 2.7.1 is running using os.popen from Sikuli.

Revision history for this message
Enix Shen (enix12enix) said :
#4

please check whether this file /System/Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python exists on your mac. i have python 2.6.1 on my mac and this file exists.

Revision history for this message
Stephan (kannelon) said :
#5

I just desinstalled Python2.6 (removed system files) and instaslled 2.7 ...I must admit I am a newbie on Mac and may be went the wrong way :-P
I tried the absolute path using the run(command) and it works!
Thanks :-)

Revision history for this message
Stephan (kannelon) said :
#6

Thanks RaiMan, that solved my question.