简体   繁体   English

Shell脚本和progressIndicator-AppleScript

[英]Shell Script & progressIndicator - AppleScript

What I have is an applescript app in xcode that runs a shell script. 我所拥有的是一个运行shell脚本的xcode中的applescript应用程序。 What I was hoping to do is have the progressIndicator move a certain amount when the command is "echo hello world" as an example but since all of my commands are sudo I have to put them in a shell script together and I can't just have the progressIndicator move in between commands (there are lots of them.) Is there a way to have the bar move when a certain command is started? 我希望做的是,以命令“ echo hello world”为例,使progressIndicator移动一定量,但是由于我的所有命令都是sudo,所以我不得不将它们放在一个shell脚本中,我不能只是是否有progressIndicator在命令之间移动(有很多)。是否有一种方法可以在启动某个命令时使栏移动? Also, is there a way to output the log of the applescript to a textView in xcode? 另外,有没有一种方法可以将AppleScript的日志输出到xcode中的textView?

You can always run the command line tool "ps" to see which processes are currently running. 您始终可以运行命令行工具“ ps”来查看当前正在运行的进程。 As such you can formulate a repeat loop and using ps can figure out which of your commands are currently running... and thus increment your progress indicator as needed. 这样,您可以制定一个重复循环,并使用ps可以找出当前正在运行的命令...,从而根据需要增加进度指示器。

Here's a ps command I've used to get a nice listing. 这是我用来获得一个不错的清单的ps命令。 You can combine this with grep to filter for your processes... 您可以将其与grep结合使用以过滤您的进程...

/bin/ps -Axcro user,pid,%cpu,command

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM