<分区>
我在跑:
python Parser.py "Bot Pick Nut"
通过 MobaXterm 在 linux 命令行中。这按预期工作,它返回 True。 我面临的问题是当通过 shell 脚本运行时它返回 false?任何人都可以建议为什么我的 shell 没有正确地将结果提供给我的 python 脚本吗?
脚本:
#!/bin/sh
python Parser.py argv[0]
命令:
./Shell.sh "Bot Pick Nut"
<分区>
我在跑:
python Parser.py "Bot Pick Nut"
通过 MobaXterm 在 linux 命令行中。这按预期工作,它返回 True。 我面临的问题是当通过 shell 脚本运行时它返回 false?任何人都可以建议为什么我的 shell 没有正确地将结果提供给我的 python 脚本吗?
脚本:
#!/bin/sh
python Parser.py argv[0]
命令:
./Shell.sh "Bot Pick Nut"
最佳答案
bash
位置参数 从 $0
开始,$1
是脚本的第一个参数,随后编号来自 $2
..$n
,其中 $0
是脚本本身的名称。
#!/bin/sh
python Parser.py "$1"
bash
中参数的简单列表,
$0 the first positional parameter, equivalent to argv[0] in C, see the first argument
$FUNCNAME the function name (attention: inside a function, $0 is still the $0 of the shell, not the function name)
$1 … $9 the argument list elements from 1 to 9
${10} … ${N} the argument list elements beyond 9 (note the parameter expansion syntax!)
$* all positional parameters except $0, see mass usage
$@ all positional parameters except $0, see mass usage
$# the number of arguments, not counting $0
关于python - Bash 脚本不处理传递的输入参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43138655/