shell - 脚本不是 en 可执行常规文件

标签 shell ubuntu

我已经使用 sudo nano yellowfin 创建了一个脚本,然后将其放入下面的代码并保存,但是当我尝试运行它时,它给我的错误是 script yellowfin 不是一个可执行的常规文件,已跳过

文件中的代码

#!/bin/bash
# USAGE: start|stop
#
case "$1" in
start)
echo "Starting Yellowfin."
/opt/yf/appserver/bin/startup.sh
;;
stop)
echo "Stopping Yellowfin."
/opt/yf/appserver/bin/shutdown.sh
;;

*)
echo “Yellowfin Service”
echo $”Usage: $0 {start|stop}”
exit 1
esac
exit 0

然后我更新

 sudo update-rc.d yellowfin defaults

最佳答案

首先确保您的脚本可以使用 chmod +x yellowfin 执行并修复 脚本缺少 LSB 标记和覆盖 在您的 bash 脚本的顶部添加:

### BEGIN INIT INFO
# Provides:          example
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Example initscript
# Description:       This file should be used to construct scripts to be
#                    placed in /etc/init.d.  This example start a
#                    single forking daemon capable of writing a pid
#                    file.  To get other behavoirs, implemend
#                    do_start(), do_stop() or other functions to
#                    override the defaults in /lib/init/init-d-script.
### END INIT INFO

关于shell - 脚本不是 en 可执行常规文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42854122/

相关文章:

linux - 需要使用 shell 脚本验证在命令行上作为参数传递的每个文件是否存在

shell - 如何使用 Github Actions 生成校验和并设置环境变量?

c++ - 从 ubuntu 连接到 Oracle 数据库

apache - 在不同的端口上部署两个不同的应用程序

linux - 加入两个文件,包括 Shell 中不匹配的行

shell - 如何检查 OS X 中 sed 的版本?

python - Databricks CLI 未在 Ubuntu 18.04 上安装

amazon-web-services - 使用 Apache Airflow 编辑存储在 AWS S3 中的 CSV,无需下载

maven - Jenkins 在 mercurial commit 之后构建

json - 如何从命令行修改 JSON 文件中的键值