【发布时间】:2014-05-13 12:48:20
【问题描述】:
我正在尝试将Terminal 可用的剪贴板内容作为参数传递给python 脚本。该脚本称为tabulate_from_cl.py,它只是打印它接收到的参数。虽然它执行没有问题,但pbpaste 的输出没有迹象
# ------------------------
# tabulate_from_cl.py
import sys
def main(args):
for each in args:
print('arg: {}\n'.format(each))
if __name__ == "__main__":
main(sys.argv[:])
# ------------------------
# lets say pbpaste contains the string 'I am residing on the clipboard'
# at the command line...
$ pbpaste | tabulate_from_cl.py
# actual output
/Users/myhomedirectroy/Desktop/tabulate_from_cl.py
# desired output
/Users/myhomedirectroy/Desktop/tabulate_from_cl.py
I am residing on the clipboard
对此我尝试了很多变体,包括将pbpaste 的内容放入一个shell 变量中,但没有产生所需的输出。我正在尝试做的事情可能吗?
【问题讨论】:
标签: python macos command-line terminal pipe