0

I'm running:

python Parser.py "Bot Pick Nut"

In linux command line via MobaXterm. This works as intended, it returns True. The issue I face is when run via the shell script it returns false? Can anyone advice why my shell is not giving the result to my python script correctly?

The Script:

#!/bin/sh
python Parser.py argv[0]

The command:

 ./Shell.sh "Bot Pick Nut"
0

1 Answer 1

1

The bash positional parameters start from $0 with $1 being the first argument for the script, subsequently numbered from $2..$n with $0 being the name of the script itself.

#!/bin/sh
python Parser.py "$1"

A simple tabulation of the arguments in 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
Sign up to request clarification or add additional context in comments.

2 Comments

Well, I feel dumb. Thanks for the assist!
I can't vote, people keep downvoting me so I don't have the rep. I couldn't mark it at the time due to the timer before you can accept an answer. I literally just got back on from having to walk half an hour to do IRL stuff.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.