如何在Mac上运行.bash文件?

时间:2017-05-19 07:33:53

标签: bash macos

I want to execute 
Path : "/Users/Trans/Downloads/solr-6.1.0"
Command: "bin/solr start -p 8983"
and 
Path : " /Users/Trans/Downloads/apache-activemq-5.12.0/bin"
Command: "./activemq console"

要在单击时使其可执行,我创建一个.command文件 有

 !#/bin/bash
 "/Users/Trans/Downloads/solr-6.1.0" bin/solr start -p 8983
 "/Users/Trans/Downloads/apache-activemq-5.12.0/bin" ./activemq console
  

给予chmode + x权限   但似乎有些事情是错的,Code没有被执行。

我的目的是创建一个批处理/重击文件,双击它应该打开终端并执行两个命令或更多。

1 个答案:

答案 0 :(得分:1)

Shebang以#!而不是!#

开头
#!/bin/bash

# verbose mode ( or -v in shebang )
set -v

cd "/Users/Trans/Downloads/solr-6.1.0" && bin/solr start -p 8983
echo "press a key to continue"
read -n1

cd "/Users/Trans/Downloads/apache-activemq-5.12.0/bin" && ./activemq console
echo "press a key to continue"
read -n1