将引号从 AppleScript 传递到 shell 脚本中 [英] Pass quotation marks into shell script from AppleScript

查看:29
本文介绍了将引号从 AppleScript 传递到 shell 脚本中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我 AppleScript 的这一部分:

I have this portion of my AppleScript:

set msgDate to "05-06-2013"
set quotedmsgDate to quoted form of "\"" & msgDate & "\"" as string
do shell script "echo send message in folder \"" & quotedmsgDate & "\">> ~/Library/Outlook/" & msgDate & ".txt"

我想要完成的是将在文件夹05-06-2013"​​中发送消息"写入 ~/Library/Outlook/05-06-2013.txt.

What I'm trying to accomplish is writing 'send message in folder "05-06-2013"' to ~/Library/Outlook/05-06-2013.txt.

它实际写的是在文件夹 05-06-2013 中发送消息".

What it actually writes is 'send message in folder 05-06-2013'.

一切都很好除了回显了quotedmsgDate周围的引号.(顺便说一句,第二行在那里的唯一原因是因为我正在围绕'引用形式'进行测试在 AppleScript 中查看它是否有所作为.它没有.)我觉得我已经尝试了所有方法,但由于某种原因,我无法使用 do shell script 语句将引号放在需要的位置.

Everything is working just fine except echoing out the quotation marks around quotedmsgDate.(By the way, the only reason that second line is in there was because I was testing around the 'quoted form of' in AppleScript to see if it made a difference. It didn't.) I feel like I've tried everything, but for some reason I just can't get the do shell script statement to put quotation marks where they need to be.

非常感谢任何帮助或见解!

Any assistance or insight is greatly appreciated!

推荐答案

尝试:

set msgDate to "05-06-2013"
set quotedmsgDate to "\"" & msgDate & "\"" as string
do shell script "echo send message in folder " & quoted form of quotedmsgDate & " >> ~/Library/Outlook/" & msgDate & ".txt"

这篇关于将引号从 AppleScript 传递到 shell 脚本中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆