下面的问题涉及被张贴在this question答案:如何摆脱这个osascript输出?
我喜欢创造我自己的功能,打开一个新的终端的概念,从而使克雷格·沃克挂在上面提到的问题,剧本适合我需要。该脚本,由Mark Liyanage写的,发现here.
该脚本是这样的:
#!/bin/sh
#
# Open a new Mac OS X terminal window with the command given
# as argument.
#
# - If there are no arguments, the new terminal window will
# be opened in the current directory, i.e. as if the command
# would be "cd `pwd`".
# - If the first argument is a directory, the new terminal will
# "cd" into that directory before executing the remaining
# arguments as command.
# - If there are arguments and the first one is not a directory,
# the new window will be opened in the current directory and
# then the arguments will be executed as command.
# - The optional, leading "-x" flag will cause the new terminal
# to be closed immediately after the executed command finishes.
#
# Written by Marc Liyanage <http://www.entropy.ch>
#
# Version 1.0
#
if [ "x-x" = x"$1" ]; then
EXIT="; exit"; shift;
fi
if [[ -d "$1" ]]; then
WD=`cd "$1"; pwd`; shift;
else
WD="'`pwd`'";
fi
COMMAND="cd $WD; [email protected]"
#echo "$COMMAND $EXIT"
osascript 2>/dev/null <<EOF
tell application "Terminal"
activate
do script with command "$COMMAND $EXIT"
end tell
EOF
我做了一个改变的链接网站上的脚本;我注释掉输出“$ COMMAND $ EXIT”的行以消除一些冗长。然而,当我运行该脚本我仍是打开的新窗口,并执行我传递,任何想法,为什么这将是发生在命令之前得到这个输出
tab 1 of window id 2835
? (我试图调用oascript之前标准错误重定向移动到/ dev/null,但其并没有区别。)
工程就像一个魅力。原始脚本有 osascript 2>/dev/null << EOF 正在将stderr重定向到/ dev/null,这就是我为什么移动它的原因。我没想过尝试将常规输出重定向到/ dev/null ......谢谢! – barclay 2010-11-15 18:43:28