开发者

syntax error near unexpected token `<' from Applescript to Python

开发者 https://www.devze.com 2023-03-19 08:21 出处:网络
I am using the following command to pass a string to python from Applescript String mytext contains the HTML body of an email starting with <...

I am using the following command to pass a string to python from Applescript

String mytext contains the HTML body of an email starting with <...

Applescript

display dialog (do shell script "/Users/mymac/Documents/'Microsoft User Data'/'Outlook Script Menu Items'/ test.py" & mytext)

Py开发者_运维百科thon

#!/usr/bin/env python

import sys
import string

def main():
    print sys.argv[1:]

if __name__ == "__main__":
    main()

How can I rectify this error?


You don't want to pass the HTML as an argument to the Python script. Instead, do something like:

display dialog (do shell script "/Users/mymac/Documents/'Microsoft User Data'/'Outlook Script Menu Items'/ test.py < webpage.html")

print sys.stdin.read()


The problem is you are executing a shell script ... by constructing a long line of text. "/Users/mymac/Documents/'Microsoft User Data'/'Outlook Script Menu Items'/ test.py" & " ... ")

but the "<" sign and the ">" sign have a special meaning for the shell.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号