# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
calculate_heap_sizes()
{
case "`uname`" in
Linux)
system_memory_in_mb=`free -m | awk '/:/ {print $2;exit}'`
system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo`
;;
FreeBSD)
system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`
system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
;;
SunOS)
system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'`
system_cpu_cores=`psrinfo | wc -l`
;;
Darwin)
system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'`
system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024`
system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'`
;;
*)
# assume reasonable defaults for e.g. a modern desktop or
# cheap server
system_memory_in_mb="2048"
system_cpu_cores="2"
;;
esac
.....................
这是dse4.5.2中的默认cassandra-env.sh
当我启动cassandra时,它说:
: not foundinstallables/dse-4.5.2/resources/cassandra/bin/cassandra: 16:
/usr/local/installables/dse-4.5.2/resources/cassandra/conf/cassandra-
env.sh:
: not foundinstallables/dse-4.5.2/resources/cassandra/bin/cassandra: 18:
/usr/local/installables/dse-4.5.2/resources/cassandra/conf/cassandra-
env.sh: {
/usr/local/installables/dse-4.5.2/resources/cassandra/bin/cassandra: 19:
/usr/local/installables/dse-4.5.2/resources/cassandra/conf/cassandra-
env.sh: Syntax error: word unexpected (expecting "in")
事后我可以看到“中”。此错误表示什么?有什么帮助吗?
最佳答案
检查行尾。
Windows使用CR LF(^ M ^ J)标记行尾。类似Unix的系统仅使用LF(^ J)。
在具有Windows样式的行尾的脚本中,^M
字符将被解释为单词的一部分,而不是空格。例如,一行如下所示:
foo
实际上可能是:
foo^M
(其中^ M是引入Windows样式的行尾的回车符)。该 shell 程序会执行失败,而不是执行
foo
,而不是执行命令foo^M
(假定存在)。错误信息:foo^M: Command not found
看起来像:
: Command not found
因为在打印^ M时它将光标移至行的开头,从而导致部分错误消息被覆盖。
使用
unix2dos
或tr -d '\r'
固定行尾。 (首先阅读unix2dos
的手册页;与大多数Unix过滤器程序不同,它默认替换其输入文件,而不是写入标准输出。)
关于bash - “Syntax error”单词意外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28980002/