将 Linux 代码转换为批处理文件格式以在 MS-DOS 中运行

发布于 2024-11-01 09:44:19 字数 449 浏览 4 评论 0原文

Linux 中的这段代码的用途是什么?我如何编写在 MS-DOS 中执行类似操作的等效代码?

#DB=CARMPAS1
[ $# -gt 0 ] && DB=$1 || DB=CARMPAS1

#  if [ !$3 ]; then
#     echo -e "\nplease enter database name, username and user password.   Usage : rebuild_db.sh <db_name>  <user_name> <password>\n"
#     exit 1
#   else if [ $1 == "load" ]; then
#      load
#      exit 0 
#  fi

我不知道为什么这些部分被注释掉,但我猜它们是打算做一些不成功的事情。也许是运行某些脚本的声明和条件

What is this block of code from linux intended to do and how do i code the equivalent that is supposed to do similar thing in MS-DOS?

#DB=CARMPAS1
[ $# -gt 0 ] && DB=$1 || DB=CARMPAS1

#  if [ !$3 ]; then
#     echo -e "\nplease enter database name, username and user password.   Usage : rebuild_db.sh <db_name>  <user_name> <password>\n"
#     exit 1
#   else if [ $1 == "load" ]; then
#      load
#      exit 0 
#  fi

I dont know why those parts were commented out but i guess they were intended to do something that was not successful. Perhaps a declaration and a condition to for some script to be run

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等风来 2024-11-08 09:44:19

以前似乎需要使用三个参数来运行脚本,例如

rebuild_db.sh <db_name>  <user_name> <password>

后来添加了一些默认值,并且允许不带参数运行(只需 rebuild_db.sh)。默认数据库名称为 CARMPAS1,但如果至少有一个命令行参数,则会从命令行读取该数据库名称。

读取具有默认值的第一个参数应该在 MS-DOS 批处理文件中工作,如下所示:

set dbname=CARMPAS1
if not "%1"=="" set dbname=%1

It seems that formerly the script was required to be run with three arguments, like

rebuild_db.sh <db_name>  <user_name> <password>

Then later on some default values were added, and running without arguments (just rebuild_db.sh) is allowed. The default database name is CARMPAS1, but it will be read from the command line if there's at least one command-line argument.

Reading the first argument with a default value should work in a MS-DOS batch file like this:

set dbname=CARMPAS1
if not "%1"=="" set dbname=%1
不知所踪 2024-11-08 09:44:19

该代码正在测试参数的数量是否大于零。
如果是,则将环境变量 DB 设置为第一个参数的值,否则将 DB 设置为值“CARMPAS1”。

The code is testing whether the number of arguments is greater than zero.
If it is, the environment variable DB is set to the value of the first argument, otherwise DB is set to the value "CARMPAS1".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文