将 Linux 代码转换为批处理文件格式以在 MS-DOS 中运行
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以前似乎需要使用三个参数来运行脚本,例如
后来添加了一些默认值,并且允许不带参数运行(只需
rebuild_db.sh
)。默认数据库名称为CARMPAS1
,但如果至少有一个命令行参数,则会从命令行读取该数据库名称。读取具有默认值的第一个参数应该在 MS-DOS 批处理文件中工作,如下所示:
It seems that formerly the script was required to be run with three arguments, like
Then later on some default values were added, and running without arguments (just
rebuild_db.sh
) is allowed. The default database name isCARMPAS1
, 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:
该代码正在测试参数的数量是否大于零。
如果是,则将环境变量 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".