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"
Inian
  • 80,270
  • 14
  • 142
  • 161
Kelly
  • 7
  • 4

1 Answers1

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
Inian
  • 80,270
  • 14
  • 142
  • 161
  • Well, I feel dumb. Thanks for the assist! – Kelly Mar 31 '17 at 10:44
  • 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. – Kelly Mar 31 '17 at 11:34