简体   繁体   English

在 shell 脚本中运行服务器后,如何运行另一个命令?

[英]How can I run another command after running a server in a shell script?

I want to run another command after running a Node.js server from a shell script on an Ubuntu box, but the second command never launch.在从 Ubuntu 框上的 shell 脚本运行 Node.js 服务器后,我想运行另一个命令,但第二个命令永远不会启动。

node server.js
xdg-open index.html

How can i fix it?我该如何解决?

You can add into start in package.json >>您可以在package.json中添加开始>>

{
  "name": "example",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node server.js && xdg-open index.html"
  },
  "dependencies": {
  },
  "devDependencies": {
  }
}

and run with npm start并使用npm 开始运行

see: npm script参见: npm 脚本

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

相关问题 如何在Shell脚本中运行此命令 - How can I run this command in a shell script 如何在脚本中在另一台服务器上运行shell脚本? - How to run shell script in another server in a script? 如何在不同服务器上的另一个 shell 脚本中运行 shell 脚本? - How to run a shell script within another shell script on a different server? 如果前一行命令将运行服务器,我该如何继续执行脚本 - how can i go on with script if previous line command will run a server 如何在 shell 脚本中使用 at 命令? - How can I use an at command in a shell script? 执行应用程序后运行shell脚本命令 - Running shell script command after executing an application 在背景中如何运行命令,该命令执行另一个运行脚本的终端 - How to run a command, which executes another terminal running a script, in the backgroud 如何在没有外壳(命令行)访问的情况下将表从一个数据库复制到同一服务器上的另一个数据库? - How can I copy a table from one database to another on the same server without shell (command line) access? 在Shell脚本中运行命令 - Running a command in shell script 如何在不评估命令的情况下从Shell脚本向Shell脚本编写命令 - How can I write a command to shell script from a shell script without evaluating the command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM