我编写了我的第一个脚本,用于通过 Apple 的 autoingestion.class 下载下载报告。它在 OSX 10.7.5 上大部分时间都可以正常工作,但在 OSX 10.8 下,它有时会重命名文件或将终端文本放入 applescript 编辑器本身。
任何人都知道如何解决/改进这个?
tell application "Terminal"
activate
delay 1 #give time to activate Terminal
tell application "System Events"
keystroke "cd " & ingestPath #path to autoingestion.class
keystroke return
keystroke "java Autoingestion " & userName & " " & userPW & " " & vendorID & " S D S " & reportDate
keystroke return
end tell
delay 0.1
set frontWindow to window 1
repeat until busy of frontWindow is false
delay 1
end repeat
#display dialog "finished"
#quit end tell
谢谢你的时间伙计们
Edit1:谢谢 您的快速回答!我尝试了第二部分,它给了我一个 Java 错误,有什么想法吗?一旦我再次拿到另一台 Macbook,我就会尝试延迟。
MacBook-Pro:~ USER$ java '/Volumes/STICK/Projekte/App_Statstiken/Apple/sales/Autoingestion' USERNAME PW VENDORID S D S 20130718
Exception in thread "main" java.lang.NoClassDefFoundError: /Volumes/STICK/Projekte/App_Statstiken/Apple/sales/Autoingestion
Caused by: java.lang.ClassNotFoundException: .Volumes.STICK.Projekte.App_Statstiken.Apple.sales.Autoingestion
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Edit2: 仅供参考:更新到新的 autoingestion.class,它使用属性来保存 userName 和 userPW。
set exePath to ingestPath
do script "java -cp " & (exePath & space & "Autoingestion autoingestion.properties" & space & vendorID & " S D S " & reportDate)
给出了autoingestion.properties缺失的错误,尽管如此
keystroke "java Autoingestion " & "autoingestion.properties" & " " & vendorID & " S D S " & reportDate
正在工作中。我试图将路径放在属性文件的前面,但没有帮助。有任何想法吗?
在职的:
do script "cd " & ingestPath & ";java Autoingestion " & userName & " " & userPW & " " & vendorID & " S D S " & reportDate